aboutsummaryrefslogtreecommitdiff
path: root/php/ext/google/protobuf/encode_decode.c
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2018-01-25 11:31:05 -0800
committerGitHub <noreply@github.com>2018-01-25 11:31:05 -0800
commit51293f36d8742b5cc351e5a877928fac77b75322 (patch)
tree4344a220f84b10a7f91a78e7906eb5b6a716f6cd /php/ext/google/protobuf/encode_decode.c
parentcbdeb6af3e3a499827ecc2345345068a1d0bee15 (diff)
downloadprotobuf-51293f36d8742b5cc351e5a877928fac77b75322.tar.gz
protobuf-51293f36d8742b5cc351e5a877928fac77b75322.tar.bz2
protobuf-51293f36d8742b5cc351e5a877928fac77b75322.zip
Fix more memory leak for php c extension (#4211)
* Fix more memory leak for php c extension * Fix memory leak for php5.5
Diffstat (limited to 'php/ext/google/protobuf/encode_decode.c')
-rw-r--r--php/ext/google/protobuf/encode_decode.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c
index b98121bb..a8c47f4d 100644
--- a/php/ext/google/protobuf/encode_decode.c
+++ b/php/ext/google/protobuf/encode_decode.c
@@ -484,11 +484,11 @@ static void map_slot_init(void* memory, upb_fieldtype_t type, zval* cache) {
// Store zval** in memory in order to be consistent with the layout of
// singular fields.
zval** holder = ALLOC(zval*);
+ *(zval***)memory = holder;
zval* tmp;
MAKE_STD_ZVAL(tmp);
PHP_PROTO_ZVAL_STRINGL(tmp, "", 0, 1);
*holder = tmp;
- *(zval***)memory = holder;
#else
*(zval**)memory = cache;
PHP_PROTO_ZVAL_STRINGL(*(zval**)memory, "", 0, 1);
@@ -521,7 +521,7 @@ static void map_slot_uninit(void* memory, upb_fieldtype_t type) {
case UPB_TYPE_BYTES: {
#if PHP_MAJOR_VERSION < 7
zval** holder = *(zval***)memory;
- php_proto_zval_ptr_dtor(*holder);
+ zval_ptr_dtor(holder);
FREE(holder);
#else
php_proto_zval_ptr_dtor(*(zval**)memory);
@@ -1621,6 +1621,7 @@ static void discard_unknown_fields(MessageHeader* msg) {
stringsink* unknown = DEREF(message_data(msg), 0, stringsink*);
if (unknown != NULL) {
stringsink_uninit(unknown);
+ FREE(unknown);
DEREF(message_data(msg), 0, stringsink*) = NULL;
}