Skip to content

Commit 2634622

Browse files
committed
Fix uninitialized memory accesses in DOM iterator
1 parent fc09eb2 commit 2634622

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

ext/dom/dom_iterators.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,13 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i
278278
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
279279
return NULL;
280280
}
281-
iterator = emalloc(sizeof(php_dom_iterator));
281+
iterator = emalloc(sizeof(*iterator));
282+
memset(iterator, 0, sizeof(*iterator));
282283
zend_iterator_init(&iterator->intern);
283-
iterator->cache_tag.modification_nr = 0;
284284

285285
ZVAL_OBJ_COPY(&iterator->intern.data, Z_OBJ_P(object));
286286
iterator->intern.funcs = &php_dom_iterator_funcs;
287287

288-
ZVAL_UNDEF(&iterator->curobj);
289-
290288
intern = Z_DOMOBJ_P(object);
291289
objmap = (dom_nnodemap_object *)intern->ptr;
292290
if (objmap != NULL) {

0 commit comments

Comments
 (0)