[php-src] master: Merge branch 'PHP-8.5'

From: Date: Mon, 10 Aug 2026 14:26:24 +0000
Subject: [php-src] master: Merge branch 'PHP-8.5'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140590@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-08-10T10:23:54-04:00 Commit: https://github.com/php/php-src/commit/9d58ce53a131f3a81f4b0e534397360e9638f3df Raw diff: https://github.com/php/php-src/commit/9d58ce53a131f3a81f4b0e534397360e9638f3df.diff Merge branch 'PHP-8.5' * PHP-8.5: Fix segfault comparing uninitialized SimpleXMLElement instances Changed paths: A ext/simplexml/tests/bug_sxe_compare_uninitialized.phpt M NEWS M ext/simplexml/simplexml.c Diff: diff --git a/NEWS b/NEWS index 2a06febbfa28..1fa28e590846 100644 --- a/NEWS +++ b/NEWS @@ -85,6 +85,8 @@ PHP NEWS element. (iliaal) . SimpleXMLElement::__construct() now raises a ValueError when the $data argument contains NUL bytes. (iliaal) + . Fixed segfault when comparing uninitialized SimpleXMLElement + instances. (iliaal) - Standard: . Added the "filter.max_filter_count" stream context option for php://filter diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 828262f18aad..94c538a40488 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1212,7 +1212,7 @@ static int sxe_objects_compare(zval *object1, zval *object2) /* {{{ */ if (sxe1->node == NULL && sxe2->node == NULL) { /* Both nodes not set: Only support equality comparison between documents. */ - if (sxe1->document->ptr == sxe2->document->ptr) { + if (sxe1->document != NULL && sxe2->document != NULL && sxe1->document->ptr == sxe2->document->ptr) { return 0; } return ZEND_UNCOMPARABLE; diff --git a/ext/simplexml/tests/bug_sxe_compare_uninitialized.phpt b/ext/simplexml/tests/bug_sxe_compare_uninitialized.phpt new file mode 100644 index 000000000000..4d915b66c3a3 --- /dev/null +++ b/ext/simplexml/tests/bug_sxe_compare_uninitialized.phpt @@ -0,0 +1,28 @@ +--TEST-- +Comparing uninitialized SimpleXMLElement instances must not segfault +--EXTENSIONS-- +simplexml +--FILE-- +<?php +class MySXE extends SimpleXMLElement { + public function __construct() {} +} +$a = new MySXE; +$b = new MySXE; +echo "self: "; +var_dump($a == $a); +echo "equal: "; +var_dump($a == $b); +echo "identical: "; +var_dump($a === $b); +$c = simplexml_load_string('<r/>'); +echo "uninit vs init: "; +var_dump($a == $c); +echo "done\n"; +?> +--EXPECT-- +self: bool(true) +equal: bool(false) +identical: bool(false) +uninit vs init: bool(false) +done

« previous php.cvs (#140590) next »