[php-src] PR #25939: ext/intl: Fix UAF in UConverter::convert() on re-entrant encoding change

From: Date: Mon, 30 Nov 2026 11:31:48 +0000
Subject: [php-src] PR #25939: ext/intl: Fix UAF in UConverter::convert() on re-entrant encoding change
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41240@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25939 Author: hohphu8 In UConverter::convert() (ext/intl/converter/converter.c), objval->src and objval->dest are passed directly into php_converter_do_convert(). If a subclass overrides toUCallback() or fromUCallback() and calls setSourceEncoding(), setDestinationEncoding(), or __construct() re-entrantly during conversion, php_converter_set_encoding() frees the active UConverter * via ucnv_close(*pcnv) while ICU is still using it, causing a use-after-free / crash. This tracks active conversions with a convert_depth counter on php_converter_object, rejects encoding changes in php_converter_set_encoding() and reinitialization in UConverter::__construct() with U_INVALID_STATE_ERROR while a conversion is in progress, and updates *pcnv before calling ucnv_close() on the previous converter. Adds ext/intl/tests/uconverter_reentrant_set_encoding.phpt covering toUCallback(), fromUCallback(), re-entrant __construct(), and recovery after normal completion and exceptions. Verified crash (SIGSEGV) -> PASS on PHP-8.4 (Debug + ZTS), with ext/intl/tests/uconverter*.phpt passing 16/16. Note: AI-assisted code audit; manually verified and reproduced locally.

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