[php-src] PR #20098: Fix GH-20085: Assertion failure when combining lazy object get_properties exception with foreach loop

From: Date: Tue, 07 Oct 2025 19:19:35 +0000
Subject: [php-src] PR #20098: Fix GH-20085: Assertion failure when combining lazy object get_properties exception with foreach loop
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-33526@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/20098 Author: nielsdos In this test, we will loop once, and then replace the object with an instance that'll throw on property construction in Z_OBJPROP_P() in the ZEND_FE_FETCH_RW VM handler. Since at that point pos >= fe_ht->nNumUsed, we exit via fe_fetch_w_exit without checking for an exception, causing incorrect continuation of the code and an eventual assertion failure. To solve this, we perform an exception check at the end of the iteration. This should be sufficient to guarantee the exception is checked in time as failure of get_properties() via Z_OBJPROP_P() will always result in an empty hash table. This should also be more efficient than the alternative fix that checks for an exception right after Z_OBJPROP_P() as that would be executed at each iteration.

« previous php.git-pulls (#33526) next »