From 82e6f32d640d3dc826c1956e01e6c491ed1f0ad1 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Wed, 6 Apr 2016 11:51:57 -0700 Subject: [PATCH] php: destroy grpc_byte_buffer after startBatch --- src/php/ext/grpc/byte_buffer.c | 1 + src/php/ext/grpc/call.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/php/ext/grpc/byte_buffer.c b/src/php/ext/grpc/byte_buffer.c index 8be0a206073..7a726de5db4 100644 --- a/src/php/ext/grpc/byte_buffer.c +++ b/src/php/ext/grpc/byte_buffer.c @@ -72,6 +72,7 @@ void byte_buffer_to_string(grpc_byte_buffer *buffer, char **out_string, while (grpc_byte_buffer_reader_next(&reader, &next) != 0) { memcpy(string + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next)); offset += GPR_SLICE_LENGTH(next); + gpr_slice_unref(next); } *out_string = string; *out_length = length; diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index 024ab70571b..a0f3d160c64 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -492,6 +492,14 @@ cleanup: if (status_details != NULL) { gpr_free(status_details); } + for (int i = 0; i < op_num; i++) { + if (ops[i].op == GRPC_OP_SEND_MESSAGE) { + grpc_byte_buffer_destroy(ops[i].data.send_message); + } + if (ops[i].op == GRPC_OP_RECV_MESSAGE) { + grpc_byte_buffer_destroy(message); + } + } RETURN_DESTROY_ZVAL(result); }