aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/slice
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-04-12 09:37:47 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-04-12 09:37:47 -0700
commit9f99c303d01c706306eb54a5cfd0a23e1e76c6e3 (patch)
treecf9288713ede510a687d9194765260ef8b0a169b /src/core/lib/slice
parentca3b32f67d2dcce8cf09612a24fee93aa69c5a7f (diff)
Handle 0-length
Diffstat (limited to 'src/core/lib/slice')
-rw-r--r--src/core/lib/slice/slice.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/core/lib/slice/slice.c b/src/core/lib/slice/slice.c
index 1cddf062cd..da5dc3e52a 100644
--- a/src/core/lib/slice/slice.c
+++ b/src/core/lib/slice/slice.c
@@ -197,6 +197,7 @@ grpc_slice grpc_slice_new_with_len(void *p, size_t len,
}
grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t length) {
+ if (length == 0) return grpc_empty_slice();
grpc_slice slice = grpc_slice_malloc(length);
memcpy(GRPC_SLICE_START_PTR(slice), source, length);
return slice;