Skip to content

Commit f1372c8

Browse files
bjoriderickr
authored andcommitted
PHPC-387: Properly init the iterator, and don't free it on dtor
1 parent 7a8c102 commit f1372c8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

php_phongo.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,9 @@ static void php_phongo_cursor_iterator_dtor(zend_object_iterator *iter TSRMLS_DC
20312031
#endif
20322032
}
20332033

2034+
#if PHP_VERSION_ID < 70000
20342035
efree(cursor_it);
2036+
#endif
20352037
} /* }}} */
20362038

20372039
static int php_phongo_cursor_iterator_valid(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
@@ -2144,6 +2146,9 @@ zend_object_iterator *php_phongo_cursor_get_iterator(zend_class_entry *ce, zval
21442146
cursor->got_iterator = 1;
21452147

21462148
cursor_it = ecalloc(1, sizeof(php_phongo_cursor_iterator));
2149+
#if PHP_VERSION_ID >= 70000
2150+
zend_iterator_init(&cursor_it->intern);
2151+
#endif
21472152

21482153
#if PHP_VERSION_ID >= 70000
21492154
ZVAL_COPY(&cursor_it->intern.data, object);

0 commit comments

Comments
 (0)