-
Notifications
You must be signed in to change notification settings - Fork 7.8k
SimpleXML's unset can break DOM objects #17040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's not related to the new classes, here is a reproducer for old DOM that repros on 8.0: <?php
$dom = new DOMDocument;
$tag = $dom->appendChild($dom->createElement("style"));
$html = simplexml_import_dom($tag);
unset($html[0]);
$tag->append("foo"); I wouldn't be surprised if you can find a reproducer for even older versions. Basically, simplexml thinks it owns the node and uses the "free resource" approach to get rid of it when unsetting. This causes the pointer to the node in the internal object to become NULL, causing a failure in all places that get the node assuming that it can't be NULL. |
Don't free the underlying nodes if we still have objects pointing to them, otherwise the objects are left with a NULL node pointer.
Don't free the underlying nodes if we still have objects pointing to them, otherwise the objects are left with a NULL node pointer.
* PHP-8.3: Fix GH-17040: SimpleXML's unset can break DOM objects
* PHP-8.4: Fix GH-17040: SimpleXML's unset can break DOM objects
Don't free the underlying nodes if we still have objects pointing to them, otherwise the objects are left with a NULL node pointer. Closes phpGH-17046.
Description
The following code:
Resulted in this output:
PHP Version
nightly
Operating System
ubuntu 22.04
The text was updated successfully, but these errors were encountered: