Commit a843b5538c2 for php

commit a843b5538c2e433a75406f89a57a5f47891e7ab3
Author: hohphu8 <kodoku169@gmail.com>
Date:   Wed Dec 2 10:24:07 2026 +0700

    ext/intl: Reject unconstructed IntlListFormatter in format()

    In IntlListFormatter::format(), 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. getErrorCode(), getErrorMessage(), __construct(), and
    listformatter_free_obj() already handle the unconstructed state safely.

    Close GH-26023

diff --git a/NEWS b/NEWS
index 162e63adb1f..5685df3ca38 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? ????, PHP 8.5.15

+- Intl:
+  . Fixed NULL pointer dereference in IntlListFormatter::format() on an
+    unconstructed object. (hohphu8)
+

 17 Dec 2026, PHP 8.5.14

diff --git a/ext/intl/listformatter/listformatter_class.c b/ext/intl/listformatter/listformatter_class.c
index c8d835170c5..5d8de38e8fb 100644
--- a/ext/intl/listformatter/listformatter_class.c
+++ b/ext/intl/listformatter/listformatter_class.c
@@ -134,6 +134,11 @@ PHP_METHOD(IntlListFormatter, format)

     intl_errors_reset(LISTFORMATTER_ERROR_P(obj));

+    if (UNEXPECTED(LISTFORMATTER_OBJECT(obj) == NULL)) {
+        zend_throw_error(NULL, "Found unconstructed IntlListFormatter");
+        RETURN_THROWS();
+    }
+
     uint32_t count = zend_hash_num_elements(ht);
     if (count == 0) {
         RETURN_EMPTY_STRING();
diff --git a/ext/intl/tests/listformatter/listformatter_unconstructed.phpt b/ext/intl/tests/listformatter/listformatter_unconstructed.phpt
new file mode 100644
index 00000000000..cc952ddaa22
--- /dev/null
+++ b/ext/intl/tests/listformatter/listformatter_unconstructed.phpt
@@ -0,0 +1,31 @@
+--TEST--
+IntlListFormatter::format() rejects an unconstructed object
+--EXTENSIONS--
+intl
+--FILE--
+<?php
+$escaped = null;
+$arg = new class($escaped) {
+    public function __construct(private &$out) {}
+    public function __toString(): string {
+        $this->out = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT)[1]['object'];
+        throw new Exception('abort constructor');
+    }
+};
+
+try {
+    new IntlListFormatter($arg);
+} catch (Exception $e) {
+}
+
+foreach ([[], ['a', 'b']] as $items) {
+    try {
+        var_dump($escaped->format($items));
+    } catch (Error $e) {
+        echo $e::class, ': ', $e->getMessage(), "\n";
+    }
+}
+?>
+--EXPECT--
+Error: Found unconstructed IntlListFormatter
+Error: Found unconstructed IntlListFormatter