[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 02/02: Fix realloc memleak in compress_buf(
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 02/02: Fix realloc memleak in compress_buf() |
Date: |
Mon, 15 Apr 2019 00:32:58 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository libmicrohttpd.
commit ef15b53cb101c378a905faa759aa95429d2e965d
Author: Tim Rühsen <address@hidden>
AuthorDate: Sun Apr 14 19:48:54 2019 +0200
Fix realloc memleak in compress_buf()
---
src/examples/http_chunked_compression.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/examples/http_chunked_compression.c
b/src/examples/http_chunked_compression.c
index 36b3e1fd..9e49c131 100644
--- a/src/examples/http_chunked_compression.c
+++ b/src/examples/http_chunked_compression.c
@@ -41,6 +41,7 @@ compress_buf (z_stream *strm, const void *src, size_t
src_size, size_t *offset,
unsigned int have;
int ret;
int flush;
+ void *tmp_dest;
*dest = NULL;
*dest_size = 0;
do
@@ -65,9 +66,14 @@ compress_buf (z_stream *strm, const void *src, size_t
src_size, size_t *offset,
ret = deflate (strm, flush);
have = CHUNK - strm->avail_out;
*dest_size += have;
- *dest = realloc (*dest, *dest_size);
- if (NULL == *dest)
- return MHD_NO;
+ tmp_dest = realloc (*dest, *dest_size);
+ if (NULL == tmp_dest)
+ {
+ free (*dest);
+ *dest = NULL;
+ return MHD_NO;
+ }
+ *dest = tmp_dest;
memcpy ((*dest) + ((*dest_size) - have), tmp, have);
}
while (0 == strm->avail_out);
--
To stop receiving notification emails like this one, please contact
address@hidden