Skip to content

Fix GH-15551: Segmentation fault (access null pointer) in ext/dom/xml_common.h #15556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
6 changes: 4 additions & 2 deletions ext/dom/dom_iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,15 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */
bool do_curobj_undef = 1;

php_dom_iterator *iterator = (php_dom_iterator *)iter;
if (Z_ISUNDEF(iterator->curobj)) {
return;
}

intern = Z_DOMOBJ_P(&iterator->curobj);
object = &iterator->intern.data;
nnmap = Z_DOMOBJ_P(object);
objmap = (dom_nnodemap_object *)nnmap->ptr;

intern = Z_DOMOBJ_P(&iterator->curobj);

if (intern != NULL && intern->ptr != NULL) {
if (objmap->nodetype != XML_ENTITY_NODE &&
objmap->nodetype != XML_NOTATION_NODE) {
Expand Down
14 changes: 14 additions & 0 deletions ext/dom/tests/gh15551.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
GH-15551 (Segmentation fault (access null pointer) in ext/dom/xml_common.h)
--EXTENSIONS--
dom
--FILE--
<?php
$fragment = new DOMDocumentFragment();
$nodes = $fragment->childNodes;
$iter = $nodes->getIterator();
$iter->next();
var_dump($iter->valid());
?>
--EXPECT--
bool(false)
Loading