Commit e0d3aa05 authored by Bo Yang's avatar Bo Yang

Fix memory leak when creating repeated field via array.

parent de44982a
......@@ -461,8 +461,7 @@ void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type,
CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)memory) TSRMLS_CC);
}
Z_DELREF_P(CACHED_TO_ZVAL_PTR(repeated_field));
RETURN_ZVAL(CACHED_TO_ZVAL_PTR(repeated_field), 1, 0);
RETURN_ZVAL(CACHED_TO_ZVAL_PTR(repeated_field), 1, 1);
} else if (Z_TYPE_P(val) == IS_OBJECT) {
if (!instanceof_function(Z_OBJCE_P(val), repeated_field_type TSRMLS_CC)) {
......
......@@ -105,6 +105,11 @@ $m = new TestMessage();
$m->mergeFromString(hex2bin('F80601'));
assert('F80601', bin2hex($m->serializeToString()));
// Test create repeated field via array.
$str_arr = array();
$m = new TestMessage();
$m->setRepeatedString($str_arr);
# $from = new TestMessage();
# $to = new TestMessage();
# TestUtil::setTestMessage($from);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment