Skip to content

Fix crashes when entity declaration is removed while still having entity references#14089

Closed
ndossche wants to merge 1 commit intophp:PHP-8.2from
ndossche:fix-entity-ref-crash
Closed

Fix crashes when entity declaration is removed while still having entity references#14089
ndossche wants to merge 1 commit intophp:PHP-8.2from
ndossche:fix-entity-ref-crash

Conversation

@ndossche
Copy link
Member

libxml doesn't do reference counting inside its node types. It's possible to remove an entity declaration out of the document, but then entity references will keep pointing to that stale declaration. This will cause crashes.

One idea would be to check when a declaration is removed, to trigger a hook that updates all references. However this means we have to keep track of all references somehow, which would be a high-overhead solution. The solution in this patch makes sure that the fields are always updated before they are read.

…ity references

libxml doesn't do reference counting inside its node types. It's
possible to remove an entity declaration out of the document, but then
entity references will keep pointing to that stale declaration. This
will cause crashes.

One idea would be to check when a declaration is removed, to trigger a
hook that updates all references. However this means we have to keep
track of all references somehow, which would be a high-overhead
solution. The solution in this patch makes sure that the fields are
always updated before they are read.
Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LCTM

@ndossche ndossche closed this in e878b9f Apr 30, 2024
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.

2 participants