Skip to content

Commit 2caad39

Browse files
committed
ext/xsl: handle xsltNewTransformContext allocation failure
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.
1 parent 171b722 commit 2caad39

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

ext/xsl/xsltprocessor.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
350350
php_libxml_increment_doc_ref(intern->doc, doc);
351351

352352
ctxt = xsltNewTransformContext(style, doc);
353+
if (UNEXPECTED(ctxt == NULL)) {
354+
goto out;
355+
}
353356
ctxt->_private = (void *) intern;
354357

355358
if (intern->parameter) {

0 commit comments

Comments
 (0)