[GIT-PULLS] [php-src] PR #22896: ext/soap: to_xml_array() heap use-after-free with illegal iterator keys.

[email protected] (devnexen) Mon, 27 Jul 2026 04:17:12 +0000
Newsgroups php.git-pulls
Message-ID <[email protected]>
Pull Request: https://github.com/php/php-src/pull/22896
Author: devnexen

Fix #22895

The return value of array_set_zval_key() was ignored, so when the key is not a legal array offset, e.g. MultipleIterator::key() returning an array, it threw and took no reference. The unconditional zval_ptr_dtor() then dropped the iterator's only reference to the borrowed value and the following Z_TRY_ADDREF_P() read freed memory.

Let array_set_zval_key() own its reference the way spl_iterator_to_array_apply() does, and stop iterating on failure.