aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/channel
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2015-07-01 16:45:34 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2015-07-01 17:12:38 -0700
commit4e4033650911582617049643fb02942a114be220 (patch)
tree825e3d0ecce59b6ae72450d9d087bd86abbb8e01 /src/core/channel
parent8a187099ec8accf4f4b9c1bcea0a71d023f6389b (diff)
Fixed leaks
Diffstat (limited to 'src/core/channel')
-rw-r--r--src/core/channel/compress_filter.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/channel/compress_filter.c b/src/core/channel/compress_filter.c
index 6100a90668..56e0a8141e 100644
--- a/src/core/channel/compress_filter.c
+++ b/src/core/channel/compress_filter.c
@@ -67,7 +67,9 @@ static int compress_send_sb(grpc_compression_algorithm algorithm,
gpr_slice_buffer tmp;
gpr_slice_buffer_init(&tmp);
did_compress = grpc_msg_compress(algorithm, slices, &tmp);
- gpr_slice_buffer_swap(slices, &tmp);
+ if (did_compress) {
+ gpr_slice_buffer_swap(slices, &tmp);
+ }
gpr_slice_buffer_destroy(&tmp);
return did_compress;
}
@@ -142,8 +144,9 @@ static void process_send_ops(grpc_call_element *elem,
case GRPC_OP_SLICE:
if (skip_compression(channeld, calld)) continue;
GPR_ASSERT(calld->remaining_slice_bytes > 0);
- /* add to calld->slices */
- gpr_slice_buffer_add(&calld->slices, sop->data.slice);
+ /* We need to copy the input because gpr_slice_buffer_add takes
+ * ownership. However, we don't own sop->data.slice, the caller does. */
+ gpr_slice_buffer_add(&calld->slices, gpr_slice_ref(sop->data.slice));
calld->remaining_slice_bytes -= GPR_SLICE_LENGTH(sop->data.slice);
if (calld->remaining_slice_bytes == 0) {
/* compress */
@@ -186,6 +189,8 @@ static void process_send_ops(grpc_call_element *elem,
case GRPC_OP_SLICE:
if (did_compress) {
if (j < calld->slices.count) {
+ /* swap the input slices for their compressed counterparts */
+ gpr_slice_unref(sop->data.slice);
sop->data.slice = gpr_slice_ref(calld->slices.slices[j++]);
}
}