From 2044fd4130edc868d99a6252658d46dd86dc50f2 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 17 Apr 2019 14:35:22 +0200 Subject: [PATCH] fix memleak --- client/tinycbor/open_memstream.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/tinycbor/open_memstream.c b/client/tinycbor/open_memstream.c index 899f3b172..0085641f9 100644 --- a/client/tinycbor/open_memstream.c +++ b/client/tinycbor/open_memstream.c @@ -66,8 +66,10 @@ static RetType write_to_buffer(void *cookie, const char *data, LenType len) { // make room size_t newalloc = newsize + newsize / 2 + 1; // give 50% more room ptr = realloc(ptr, newalloc); - if (ptr == NULL) + if (ptr == NULL) { + free(ptr); return -1; + ) b->alloc = newalloc; *b->ptr = ptr; }