aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar murgatroid99 <michael.lumish@gmail.com>2015-01-29 13:50:56 -0800
committerGravatar murgatroid99 <michael.lumish@gmail.com>2015-01-29 13:50:56 -0800
commitc4c3bff8140282127e34ed1e2d83082866db2d1f (patch)
treea3464029d2a3f2336cf6a7844caf5fad400094d8
parentd87c9ea3c9aec16fff5f52dd221d728701c78dcf (diff)
Fixed memory leak in PHP byte buffer creation
-rw-r--r--src/php/ext/grpc/byte_buffer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/php/ext/grpc/byte_buffer.c b/src/php/ext/grpc/byte_buffer.c
index e2f63e3413..29d6fa0357 100644
--- a/src/php/ext/grpc/byte_buffer.c
+++ b/src/php/ext/grpc/byte_buffer.c
@@ -16,9 +16,10 @@
#include "grpc/support/slice.h"
grpc_byte_buffer *string_to_byte_buffer(char *string, size_t length) {
- gpr_slice slice = gpr_slice_malloc(length);
- memcpy(GPR_SLICE_START_PTR(slice), string, length);
- return grpc_byte_buffer_create(&slice, 1);
+ gpr_slice slice = gpr_slice_from_copied_buffer(string, length);
+ grpc_byte_buffer *buffer = grpc_byte_buffer_create(&slice, 1);
+ gpr_slice_unref(slice);
+ return buffer;
}
void byte_buffer_to_string(grpc_byte_buffer *buffer, char **out_string,