Skip to content

Fix segfault comparing uninitialized SimpleXMLElement instances - #23067

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/sxe-compare-uninitialized
Open

Fix segfault comparing uninitialized SimpleXMLElement instances#23067
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/sxe-compare-uninitialized

Conversation

@iliaal

@iliaal iliaal commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

sxe_objects_compare reaches sxe1->document->ptr whenever both operands have a NULL node, without checking that document is set. A subclass whose constructor skips parent::__construct leaves both fields NULL, so new MySXE == new MySXE dereferences NULL and segfaults. Two unset documents now compare equal, and an unset one against a live document is uncomparable, matching the node comparison directly above.

sxe_objects_compare dereferenced document->ptr when both nodes were
NULL without checking document. A subclass that skips parent
__construct leaves document NULL, so $a == $b segfaulted. Treat two
NULL documents as equal and mixed NULL/non-NULL as uncomparable.

Closes phpGH-23067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant