Skip to content

Commit dccd29c

Browse files
committed
Fix staleness check
1 parent a75c85a commit dccd29c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/dom/nodelist.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,20 @@ PHP_METHOD(DOMNodeList, item)
185185
bool restart = true;
186186
int relative_index = index;
187187
if (index >= objmap->cached_obj_index && objmap->cached_obj && !php_dom_is_cache_tag_stale_from_node(&objmap->cache_tag, nodep)) {
188-
nodep = dom_object_get_node(objmap->cached_obj);
188+
xmlNodePtr cached_obj_xml_node = dom_object_get_node(objmap->cached_obj);
189+
189190
/* The node cannot be NULL if the cache is valid. If it is NULL, then it means we
190191
* forgot an invalidation somewhere. Take the defensive programming approach and invalidate
191192
* it here if it's NULL (except in debug mode where we would want to catch this). */
192-
if (UNEXPECTED(nodep == NULL)) {
193+
if (UNEXPECTED(cached_obj_xml_node == NULL)) {
193194
#if ZEND_DEBUG
194195
ZEND_UNREACHABLE();
195196
#endif
196197
reset_objmap_cache(objmap);
197198
} else {
198199
restart = false;
199200
relative_index -= objmap->cached_obj_index;
201+
nodep = cached_obj_xml_node;
200202
}
201203
}
202204
if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) {

0 commit comments

Comments
 (0)