Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ext/dom/parentnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNod
dom_object *newNodeObj;
int stricterror;

if (document == NULL) {
php_dom_throw_error(HIERARCHY_REQUEST_ERR, 1);
return NULL;
}

if (contextNode->type == XML_DOCUMENT_NODE || contextNode->type == XML_HTML_DOCUMENT_NODE) {
documentNode = (xmlDoc *) contextNode;
} else {
Expand Down
17 changes: 17 additions & 0 deletions ext/dom/tests/bug79968.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
dom: Bug #79968 - Crash when calling before without valid hierachy
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php

$cdata = new DOMText;

try {
$cdata->before("string");
} catch (DOMException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Hierarchy Request Error