From 3b7a5f451546888ad96aaa143ef86fea904a03ec Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Tue, 5 Dec 2017 16:44:19 -0800 Subject: Fix several more memory leak --- php/ext/google/protobuf/def.c | 1 + php/ext/google/protobuf/message.c | 8 ++++---- php/ext/google/protobuf/type_check.c | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'php/ext') diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 13f7cdd6..55291e23 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -249,6 +249,7 @@ PHP_METHOD(Descriptor, getField) { MAKE_STD_ZVAL(field_hashtable_value); ZVAL_OBJ(field_hashtable_value, field_descriptor_type->create_object( field_descriptor_type TSRMLS_CC)); + Z_DELREF_P(field_hashtable_value); #else field_hashtable_value = field_descriptor_type->create_object(field_descriptor_type TSRMLS_CC); diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 3fce2c17..b11c7215 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -374,7 +374,7 @@ PHP_METHOD(Message, whichOneof) { LOWER_FIELD) \ PHP_METHOD(UPPER_CLASS, get##UPPER_FIELD) { \ zval member; \ - PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 1); \ + PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 0); \ PHP_PROTO_FAKE_SCOPE_BEGIN(LOWER_CLASS##_type); \ zval* value = message_get_property_internal(getThis(), &member TSRMLS_CC); \ PHP_PROTO_FAKE_SCOPE_END; \ @@ -387,7 +387,7 @@ PHP_METHOD(Message, whichOneof) { return; \ } \ zval member; \ - PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 1); \ + PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 0); \ message_set_property_internal(getThis(), &member, value TSRMLS_CC); \ PHP_PROTO_RETVAL_ZVAL(getThis()); \ } @@ -396,7 +396,7 @@ PHP_METHOD(Message, whichOneof) { LOWER_FIELD) \ PHP_METHOD(UPPER_CLASS, get##UPPER_FIELD) { \ zval member; \ - PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 1); \ + PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 0); \ PHP_PROTO_FAKE_SCOPE_BEGIN(LOWER_CLASS##_type); \ message_get_oneof_property_internal(getThis(), &member, \ return_value TSRMLS_CC); \ @@ -409,7 +409,7 @@ PHP_METHOD(Message, whichOneof) { return; \ } \ zval member; \ - PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 1); \ + PHP_PROTO_ZVAL_STRING(&member, LOWER_FIELD, 0); \ message_set_property_internal(getThis(), &member, value TSRMLS_CC); \ PHP_PROTO_RETVAL_ZVAL(getThis()); \ } diff --git a/php/ext/google/protobuf/type_check.c b/php/ext/google/protobuf/type_check.c index 37171426..85f5051e 100644 --- a/php/ext/google/protobuf/type_check.c +++ b/php/ext/google/protobuf/type_check.c @@ -532,6 +532,7 @@ void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type, map_field_handlers->write_dimension( CACHED_TO_ZVAL_PTR(map_field), &key, CACHED_PTR_TO_ZVAL_PTR((CACHED_VALUE*)value) TSRMLS_CC); + zval_dtor(&key); } RETURN_ZVAL(CACHED_TO_ZVAL_PTR(map_field), 1, 1); -- cgit v1.2.3