summaryrefslogtreecommitdiffstats
path: root/programs/lz4io.c
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-04-20 09:05:54 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-04-20 09:05:54 (GMT)
commitcbcdd88ccb97632015cf3732b46f8800e62e337b (patch)
tree3d2d8f6e6240a5d476b8064ed531de06a2437bb5 /programs/lz4io.c
parente18aa907985da9ccbeb1684517d0f8e77e189984 (diff)
downloadlz4-cbcdd88ccb97632015cf3732b46f8800e62e337b.zip
lz4-cbcdd88ccb97632015cf3732b46f8800e62e337b.tar.gz
lz4-cbcdd88ccb97632015cf3732b46f8800e62e337b.tar.bz2
Fixed frame concatenation
Diffstat (limited to 'programs/lz4io.c')
-rw-r--r--programs/lz4io.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index cbf366b..40bdbb7 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -820,18 +820,19 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE
}
/* Main Loop */
- for (;;)
+ for (;nextToLoad;)
{
size_t readSize;
size_t pos = 0;
size_t decodedBytes = ress.dstBufferSize;
/* Read input */
- readSize = fread(ress.srcBuffer, 1, ress.srcBufferSize, srcFile);
+ if (nextToLoad > ress.srcBufferSize) nextToLoad = ress.srcBufferSize;
+ readSize = fread(ress.srcBuffer, 1, nextToLoad, srcFile);
if (!readSize)
break; /* empty file or stream */
- while (nextToLoad && ((pos < readSize) || (decodedBytes == ress.dstBufferSize))) /* still to read, or still to flush */
+ while ((pos < readSize) || (decodedBytes == ress.dstBufferSize)) /* still to read, or still to flush */
{
/* Decode Input (at least partially) */
size_t remaining = readSize - pos;
@@ -839,6 +840,7 @@ static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE* srcFile, FILE
nextToLoad = LZ4F_decompress(ress.dCtx, ress.dstBuffer, &decodedBytes, (char*)(ress.srcBuffer)+pos, &remaining, NULL);
if (LZ4F_isError(nextToLoad)) EXM_THROW(66, "Decompression error : %s", LZ4F_getErrorName(nextToLoad));
pos += remaining;
+ if (!nextToLoad) break;
if (decodedBytes)
{