# HG changeset patch # User Matti Hamalainen # Date 1425262650 -7200 # Node ID 97ccd6d972ffcf1e7c681dcf3d0e7f24795e8c57 # Parent e98bc627ad08897a0abe73cbf69f4bdd4e6d0832 Comments, cosmetics. diff -r e98bc627ad08 -r 97ccd6d972ff src/dmzlib.c --- a/src/dmzlib.c Mon Mar 02 04:13:56 2015 +0200 +++ b/src/dmzlib.c Mon Mar 02 04:17:30 2015 +0200 @@ -325,7 +325,7 @@ } else { - Uint8 *p; + Uint8 *ptr; int len, dist; if (z == 256) { @@ -352,21 +352,23 @@ "Bad Huffman block distance.\n"); } + // Check if output buffer needs to expand if (outBuffer + len > ctx->outBufferEnd) { if ((ret = dmZLibExpand(ctx, outBuffer, len)) != DMERR_OK) return ret; outBuffer = ctx->outBuffer; } - p = (Uint8 *) (outBuffer - dist); + + ptr = outBuffer - dist; if (dist == 1) { // run of one byte; common in images. - Uint8 v = *p; + Uint8 v = *ptr; do { *outBuffer++ = v; } while (--len); } else { - do { *outBuffer++ = *p++; } while (--len); + do { *outBuffer++ = *ptr++; } while (--len); } } } @@ -526,6 +528,7 @@ "Read past buffer, probably corrupt compressed data.\n"); } + // Check if output buffer needs to expand if (ctx->outBuffer + len > ctx->outBufferEnd && (ret = dmZLibExpand(ctx, ctx->outBuffer, len)) != DMERR_OK) { @@ -534,6 +537,7 @@ ret, dmErrorStr(ret)); } + // Copy uncompressed data memcpy(ctx->outBuffer, ctx->inBuffer, len); ctx->inBuffer += len; ctx->outBuffer += len;