From 879f0c10597b1e6d526c344f0c90168f5df7ddd3 Mon Sep 17 00:00:00 2001 From: Benny Morgan Date: Sun, 30 Jun 2013 21:49:08 +0200 Subject: [PATCH] - Fix - buf is assigned to to cm->cm_data with is defined 'uint8_t cm_data[CWS_NETMSGSIZE];' part of the cwc_message_t, never malloc'd and should be free'd (cherry picked from commit 61491f394a92bfe20b18b61d2a130bf3a670efdc) --- src/cwc.c | 1 - src/filebundle.c | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cwc.c b/src/cwc.c index 7308a179..afdb51eb 100644 --- a/src/cwc.c +++ b/src/cwc.c @@ -497,7 +497,6 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid, int enq) buf[5] = sid; if((len = des_encrypt(buf, len, cwc)) <= 0) { - free(buf); free(cm); return -1; } diff --git a/src/filebundle.c b/src/filebundle.c index 295ed00f..0ea7f324 100644 --- a/src/filebundle.c +++ b/src/filebundle.c @@ -78,18 +78,16 @@ static uint8_t *_fb_inflate ( const uint8_t *data, size_t size, size_t orig ) { int err; z_stream zstr; - uint8_t *bufin, *bufout; + uint8_t *bufout; /* Setup buffers */ - bufin = malloc(size); bufout = malloc(orig); - memcpy(bufin, data, size); /* Setup zlib */ memset(&zstr, 0, sizeof(zstr)); inflateInit2(&zstr, 31); zstr.avail_in = size; - zstr.next_in = bufin; + zstr.next_in = data; zstr.avail_out = orig; zstr.next_out = bufout; @@ -99,7 +97,7 @@ static uint8_t *_fb_inflate ( const uint8_t *data, size_t size, size_t orig ) free(bufout); bufout = NULL; } - free(bufin); + inflateEnd(&zstr); return bufout;