[php-src] PR #26023: ext/intl: Reject unconstructed IntlListFormatter in format()
| From: | hohphu8 | Date: | Wed, 02 Dec 2026 03:33:42 +0000 |
| Subject: | [php-src] PR #26023: ext/intl: Reject unconstructed IntlListFormatter in format() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41352@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/26023
Author: hohphu8
In
IntlListFormatter::format()
(ext/intl/listformatter/listformatter_class.c), LISTFORMATTER_OBJECT(obj)
(obj->lf_data.ulistfmt) is not checked for NULL before being passed to
ulistfmt_format(). If an unconstructed IntlListFormatter instance escapes
from a failed constructor call (for example via
debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT) inside a Stringable
$locale argument), calling format() with a non-empty array triggers a NULL
pointer dereference (SIGSEGV), and calling format([]) silently returns
"".
Check LISTFORMATTER_OBJECT(obj) == NULL in IntlListFormatter::format()
before the empty-array fast path and throw Error with "Found unconstructed
IntlListFormatter", matching the convention used across other ext/intl
classes such as IntlRelativeDateTimeFormatter, NumberFormatter,
MessageFormatter, and IntlDateFormatter. Verified
getErrorCode(), getErrorMessage(), __construct(), and
listformatter_free_obj() already handle the unconstructed state safely.
Added a regression test (ext/intl/tests/listformatter/listformatter_unconstructed.phpt)
covering both empty and non-empty inputs on an unconstructed IntlListFormatter.
Confirmed the test crashes with SIGSEGV before the fix and passes cleanly
(ext/intl/tests/listformatter/, 9/9) on PHP-8.5 (Debug + ZTS).