aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/slice
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-11-23 15:07:43 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-11-23 15:07:43 -0800
commitb1bb50ecc133a6887009175e0c0265962d03cd96 (patch)
tree8132eb4287a0567da6ad8f7710e314f789beb5b3 /src/core/lib/slice
parente150fff57ef947998ce8f45da112ed45ae01bacb (diff)
Fix correctness, mem leak
Diffstat (limited to 'src/core/lib/slice')
-rw-r--r--src/core/lib/slice/slice.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core/lib/slice/slice.c b/src/core/lib/slice/slice.c
index aecee88dbf..f0ad9f4881 100644
--- a/src/core/lib/slice/slice.c
+++ b/src/core/lib/slice/slice.c
@@ -327,6 +327,7 @@ grpc_slice grpc_slice_split_tail(grpc_slice *source, size_t split) {
tail.data.refcounted.bytes = source->data.refcounted.bytes + split;
tail.data.refcounted.length = tail_length;
}
+ source->refcount = source->refcount->sub_refcount;
source->data.refcounted.length = split;
}
@@ -352,6 +353,7 @@ grpc_slice grpc_slice_split_head(grpc_slice *source, size_t split) {
head.refcount = NULL;
head.data.inlined.length = (uint8_t)split;
memcpy(head.data.inlined.bytes, source->data.refcounted.bytes, split);
+ source->refcount = source->refcount->sub_refcount;
source->data.refcounted.bytes += split;
source->data.refcounted.length -= split;
} else {
@@ -364,6 +366,7 @@ grpc_slice grpc_slice_split_head(grpc_slice *source, size_t split) {
/* Point into the source array */
head.data.refcounted.bytes = source->data.refcounted.bytes;
head.data.refcounted.length = split;
+ source->refcount = source->refcount->sub_refcount;
source->data.refcounted.bytes += split;
source->data.refcounted.length -= split;
}