[php-src] PR #17343: Fix GH-11874: intl causing segfault in docker images
| From: | nielsdos | Date: | Fri, 03 Jan 2025 15:51:20 +0000 |
| Subject: | [php-src] PR #17343: Fix GH-11874: intl causing segfault in docker images | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-30221@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/17343
Author: nielsdos
The segfault happens because zoi->wrapping_obj points to an object that has been freed. This
wrapping_obj is set in IntlIterator_from_StringEnumeration(). Notice how the refcount is not
increased in this function. By switching to ZVAL_OBJ_COPY, the segfault disappears.
We also need to move the responsibility of destroying the iterator to the iterator itself and keep
the object data destruction in the object destruction. The existing code used a weird recursive
destruction between the iterator and object that was too hard to understand to be honest. This patch
simplifies everything and in the process gets rid of the leak.
Iterators that are embedded are now responsible for their own memory cleanup.