]> granicus.if.org Git - php/commitdiff
Fix possible memory leak
authorAnatol Belski <ab@php.net>
Tue, 20 Feb 2018 07:23:25 +0000 (08:23 +0100)
committerAnatol Belski <ab@php.net>
Tue, 20 Feb 2018 07:23:25 +0000 (08:23 +0100)
ext/date/php_date.c

index bf2997d94670df93291ad46298735d8115e19ccf..3d0b885f404cedc3005cbceb31c32f25d4151eed 100644 (file)
@@ -2004,13 +2004,15 @@ static const zend_object_iterator_funcs date_period_it_funcs = {
 
 zend_object_iterator *date_object_period_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */
 {
-       date_period_it *iterator = emalloc(sizeof(date_period_it));
+       date_period_it *iterator;
 
        if (by_ref) {
                zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
                return NULL;
        }
 
+       iterator = emalloc(sizeof(date_period_it));
+
        zend_iterator_init((zend_object_iterator*)iterator);
 
        ZVAL_COPY(&iterator->intern.data, object);