From 8b33ed404ebbe56157e455c50b8ffaa4e71174f6 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 11 Dec 2014 15:58:58 +0100 Subject: [PATCH] Always store a NULL character at the end of a LinphoneBuffer. --- coreapi/buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coreapi/buffer.c b/coreapi/buffer.c index 8e44f832b..9db65798e 100644 --- a/coreapi/buffer.c +++ b/coreapi/buffer.c @@ -78,8 +78,9 @@ const uint8_t * linphone_buffer_get_content(const LinphoneBuffer *buffer) { void linphone_buffer_set_content(LinphoneBuffer *buffer, const uint8_t *content, size_t size) { buffer->size = size; if (buffer->content) belle_sip_free(buffer->content); - buffer->content = belle_sip_malloc(size); + buffer->content = belle_sip_malloc(size + 1); memcpy(buffer->content, content, size); + ((char *)buffer->content)[size] = '\0'; } const char * linphone_buffer_get_string_content(const LinphoneBuffer *buffer) {