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;