ext/xsl: handle xsltNewTransformContext allocation failure#21887
ext/xsl: handle xsltNewTransformContext allocation failure#21887iliaal wants to merge 2 commits intophp:PHP-8.4from
Conversation
xsltNewTransformContext can return NULL on libxslt-internal allocation failure. The next line dereferences ctxt unconditionally to set ctxt->_private, segfaulting on OOM. Bail through the existing out: label, which already handles secPrefs/intern->doc cleanup. xsltFreeTransformContext(NULL) is a documented no-op in libxslt.
|
I see .... can you do just one PR please for both. Those are kind of unlikely to happen, can t reproduce beside OOM ... Thanks. |
|
I do not mind keeping 21886 separated however the two others are a bit more like "defensive programming". |
|
Ok, I'll keep 86 separate, fold 88 into this one and close 88. |
If xmlStrdup fails for either href or prefix in xsl_add_ns_def, the malformed xmlNs (NULL href, or NULL prefix when one was expected) was linked into node->nsDef. Subsequent libxml2 traversal of the namespace chain dereferenced those NULLs. Free the xmlNs via xmlFreeNs and return without linking it.
Is that true or is that what your agent says? The prefix can certainly be NULL, and I believe the href can also be NULL. |
|
Two related defensive fixes in ext/xsl, folded per the #21888 review.
xsltNewTransformContextreturns NULL on libxslt-internal allocation failure; the next line dereferencedctxtto set_privateand segfaulted. Bail through the existingout:label, which handlessecPrefsandintern->doccleanup.xsltFreeTransformContext(NULL)is a documented no-op in libxslt.xmlStrdupfails for eitherhreforprefixinxsl_add_ns_def, the partially-constructedxmlNs(NULLhref, or NULLprefixwhen one was expected) was linked intonode->nsDef. Subsequent libxml2 traversal of the namespace chain dereferenced those NULLs. Free thexmlNsviaxmlFreeNsand return without linking it.