Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
3b7a5f45
Commit
3b7a5f45
authored
Dec 06, 2017
by
Bo Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix several more memory leak
parent
7d343715
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
6 deletions
+27
-6
def.c
php/ext/google/protobuf/def.c
+1
-0
message.c
php/ext/google/protobuf/message.c
+4
-4
type_check.c
php/ext/google/protobuf/type_check.c
+1
-0
memory_leak_test.php
php/tests/memory_leak_test.php
+21
-2
No files found.
php/ext/google/protobuf/def.c
View file @
3b7a5f45
...
...
@@ -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
);
...
...
php/ext/google/protobuf/message.c
View file @
3b7a5f45
...
...
@@ -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()); \
}
...
...
php/ext/google/protobuf/type_check.c
View file @
3b7a5f45
...
...
@@ -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
);
...
...
php/tests/memory_leak_test.php
View file @
3b7a5f45
...
...
@@ -106,15 +106,34 @@ $m->mergeFromString(hex2bin('F80601'));
assert
(
'F80601'
,
bin2hex
(
$m
->
serializeToString
()));
// Test create repeated field via array.
$str_arr
=
array
();
$str_arr
=
array
(
"abc"
);
$m
=
new
TestMessage
();
$m
->
setRepeatedString
(
$str_arr
);
// Test create map field via array.
$str_arr
=
array
();
$str_arr
=
array
(
"abc"
=>
"abc"
);
$m
=
new
TestMessage
();
$m
->
setMapStringString
(
$str_arr
);
// Test unset
$from
=
new
TestMessage
();
TestUtil
::
setTestMessage
(
$from
);
unset
(
$from
);
// Test wellknown
$from
=
new
\Google\Protobuf\Timestamp
();
$from
->
setSeconds
(
1
);
assert
(
1
,
$from
->
getSeconds
());
$from
=
new
\Google\Protobuf\Value
();
$from
->
setNumberValue
(
1
);
assert
(
1
,
$from
->
getNumberValue
());
// Test descriptor
$pool
=
\Google\Protobuf\DescriptorPool
::
getGeneratedPool
();
$desc
=
$pool
->
getDescriptorByClassName
(
"\Foo\TestMessage"
);
$field
=
$desc
->
getField
(
1
);
# $from = new TestMessage();
# $to = new TestMessage();
# TestUtil::setTestMessage($from);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment