aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/ext
diff options
context:
space:
mode:
authorGravatar ZhouyihaiDing <ddyihai@google.com>2017-12-06 18:31:40 +0000
committerGravatar Zhouyihai Ding <ddyihai@google.com>2018-01-23 13:02:38 -0800
commit04648794484e758b66340c12095e0036a538cad4 (patch)
tree62377ddb2ee75762a0f0cad45d265f63495fe565 /src/php/ext
parentbadfd4144304ea29b17c49d3d8b18645514941b1 (diff)
php-memory-leak
Diffstat (limited to 'src/php/ext')
-rw-r--r--src/php/ext/grpc/call.c16
-rw-r--r--src/php/ext/grpc/call.h3
2 files changed, 16 insertions, 3 deletions
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c
index c4997f720d..9c0f3f8a91 100644
--- a/src/php/ext/grpc/call.c
+++ b/src/php/ext/grpc/call.c
@@ -174,6 +174,18 @@ bool create_metadata_array(zval *array, grpc_metadata_array *metadata) {
return true;
}
+void grpc_php_metadata_array_destroy_including_entries(
+ grpc_metadata_array* array) {
+ size_t i;
+ if (array->metadata) {
+ for (i = 0; i < array->count; i++) {
+ grpc_slice_unref(array->metadata[i].key);
+ grpc_slice_unref(array->metadata[i].value);
+ }
+ }
+ grpc_metadata_array_destroy(array);
+}
+
/* Wraps a grpc_call struct in a PHP object. Owned indicates whether the
struct should be destroyed at the end of the object's lifecycle */
zval *grpc_php_wrap_call(grpc_call *wrapped, bool owned TSRMLS_DC) {
@@ -502,8 +514,8 @@ PHP_METHOD(Call, startBatch) {
}
cleanup:
- grpc_metadata_array_destroy(&metadata);
- grpc_metadata_array_destroy(&trailing_metadata);
+ grpc_php_metadata_array_destroy_including_entries(&metadata);
+ grpc_php_metadata_array_destroy_including_entries(&trailing_metadata);
grpc_metadata_array_destroy(&recv_metadata);
grpc_metadata_array_destroy(&recv_trailing_metadata);
grpc_slice_unref(recv_status_details);
diff --git a/src/php/ext/grpc/call.h b/src/php/ext/grpc/call.h
index 5bde5d5390..104ac301c1 100644
--- a/src/php/ext/grpc/call.h
+++ b/src/php/ext/grpc/call.h
@@ -69,5 +69,6 @@ void grpc_init_call(TSRMLS_D);
/* Populates a grpc_metadata_array with the data in a PHP array object.
Returns true on success and false on failure */
bool create_metadata_array(zval *array, grpc_metadata_array *metadata);
-
+void grpc_php_metadata_array_destroy_including_entries(
+ grpc_metadata_array* array);
#endif /* NET_GRPC_PHP_GRPC_CHANNEL_H_ */