Skip to content

Commit 884d19f

Browse files
committed
Merge branch 'pull-request/57' into php7
* pull-request/57: Fix memory leak in y_write_object_callback()
2 parents a0519c2 + 190a670 commit 884d19f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

emit.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ y_write_object_callback (
718718
zval *ztag;
719719
zval *zdata;
720720
zend_string *str_key;
721+
int result;
721722

722723
/* call the user function */
723724
if (FAILURE == call_user_function(EG(function_table), NULL,
@@ -734,6 +735,7 @@ y_write_object_callback (
734735
php_error_docref(NULL, E_WARNING,
735736
"Expected callback for class '%s'"
736737
" to return an array", clazz_name);
738+
zval_ptr_dtor(&zret);
737739
return FAILURE;
738740
}
739741

@@ -760,10 +762,12 @@ y_write_object_callback (
760762
}
761763
zend_string_release(str_key);
762764

763-
764765
/* emit surrogate object and tag */
765-
return y_write_zval(
766+
result = y_write_zval(
766767
state, zdata, (yaml_char_t *) Z_STRVAL_P(ztag));
768+
769+
zval_ptr_dtor(&zret);
770+
return result;
767771
}
768772
/* }}} */
769773

0 commit comments

Comments
 (0)