From 595623391773378659dadd4243994c88e831289f Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Fri, 5 Jul 2013 09:33:49 +0100 Subject: [PATCH] filebundle: reverse changes made in PR283 The zlib input buffer is not defined const, therefore the extra malloc/memcpy is required. --- src/filebundle.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/filebundle.c b/src/filebundle.c index 0ea7f324..295ed00f 100644 --- a/src/filebundle.c +++ b/src/filebundle.c @@ -78,16 +78,18 @@ static uint8_t *_fb_inflate ( const uint8_t *data, size_t size, size_t orig ) { int err; z_stream zstr; - uint8_t *bufout; + uint8_t *bufin, *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 = data; + zstr.next_in = bufin; zstr.avail_out = orig; zstr.next_out = bufout; @@ -97,7 +99,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;