Fix GH-16316: DOMXPath breaks when not initialized properly

Closes GH-16330.
This commit is contained in:
Niels Dossche 2024-10-09 18:11:22 +02:00
parent 509fec8ee6
commit 1d0fbdf449
No known key found for this signature in database
GPG key ID: B8A8AD166DF0E2E5
3 changed files with 41 additions and 0 deletions

View file

@ -264,6 +264,11 @@ int dom_xpath_document_read(dom_object *obj, zval *retval)
docp = (xmlDocPtr) ctx->doc;
}
if (UNEXPECTED(!docp)) {
php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true);
return FAILURE;
}
php_dom_create_object((xmlNodePtr) docp, retval, obj);
return SUCCESS;
}