fixed streaming decoder
This commit is contained in:
@@ -187,7 +187,7 @@ size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bp
|
|||||||
return cSize;
|
return cSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t ZSTD_copyUncompressedBlock(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
|
static size_t ZSTD_copyRawBlock(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
|
||||||
{
|
{
|
||||||
if (srcSize > maxDstSize) return ERROR(dstSize_tooSmall);
|
if (srcSize > maxDstSize) return ERROR(dstSize_tooSmall);
|
||||||
memcpy(dst, src, srcSize);
|
memcpy(dst, src, srcSize);
|
||||||
@@ -486,10 +486,10 @@ FORCE_INLINE size_t ZSTD_execSequence(BYTE* op,
|
|||||||
const BYTE* match = op - sequence.offset;
|
const BYTE* match = op - sequence.offset;
|
||||||
|
|
||||||
/* check */
|
/* check */
|
||||||
//if (match > op) return ERROR(corruption_detected); /* address space overflow test (is clang optimizer removing this test ?) */
|
//if (match > op) return ERROR(corruption_detected); /* address space overflow test (is clang optimizer wrongly removing this test ?) */
|
||||||
if (sequence.offset > (size_t)op) return ERROR(corruption_detected); /* address space overflow test (this test seems kept by clang optimizer) */
|
if (sequence.offset > (size_t)op) return ERROR(corruption_detected); /* address space overflow test (this test seems kept by clang optimizer) */
|
||||||
if (match < vBase) return ERROR(corruption_detected);
|
if (match < vBase) return ERROR(corruption_detected);
|
||||||
|
|
||||||
if (match < base) match = dictEnd - (base-match); /* only works if match + matchLength <= dictEnd */
|
if (match < base) match = dictEnd - (base-match); /* only works if match + matchLength <= dictEnd */
|
||||||
|
|
||||||
/* close range match, overlap */
|
/* close range match, overlap */
|
||||||
@@ -663,7 +663,7 @@ size_t ZSTD_decompressDCtx(ZSTD_DCtx* ctx, void* dst, size_t maxDstSize, const v
|
|||||||
decodedSize = ZSTD_decompressBlock(ctx, op, oend-op, ip, cBlockSize);
|
decodedSize = ZSTD_decompressBlock(ctx, op, oend-op, ip, cBlockSize);
|
||||||
break;
|
break;
|
||||||
case bt_raw :
|
case bt_raw :
|
||||||
decodedSize = ZSTD_copyUncompressedBlock(op, oend-op, ip, cBlockSize);
|
decodedSize = ZSTD_copyRawBlock(op, oend-op, ip, cBlockSize);
|
||||||
break;
|
break;
|
||||||
case bt_rle :
|
case bt_rle :
|
||||||
return ERROR(GENERIC); /* not yet supported */
|
return ERROR(GENERIC); /* not yet supported */
|
||||||
@@ -744,6 +744,7 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSize, con
|
|||||||
ctx->phase = 2;
|
ctx->phase = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->previousDstEnd = dst;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,7 +757,7 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSize, con
|
|||||||
rSize = ZSTD_decompressBlock(ctx, dst, maxDstSize, src, srcSize);
|
rSize = ZSTD_decompressBlock(ctx, dst, maxDstSize, src, srcSize);
|
||||||
break;
|
break;
|
||||||
case bt_raw :
|
case bt_raw :
|
||||||
rSize = ZSTD_copyUncompressedBlock(dst, maxDstSize, src, srcSize);
|
rSize = ZSTD_copyRawBlock(dst, maxDstSize, src, srcSize);
|
||||||
break;
|
break;
|
||||||
case bt_rle :
|
case bt_rle :
|
||||||
return ERROR(GENERIC); /* not yet handled */
|
return ERROR(GENERIC); /* not yet handled */
|
||||||
|
|||||||
@@ -360,8 +360,8 @@ size_t benchMem(void* src, size_t srcSize, U32 benchNb)
|
|||||||
free(buff2);
|
free(buff2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
iend = ip + 3 + blockSize; // Get end of first block
|
iend = ip + 3 + blockSize; /* End of first block */
|
||||||
ip += 3; // jump first block header
|
ip += 3; /* skip block header */
|
||||||
ip += ZSTD_decodeLiteralsBlock(g_dctxPtr, ip, iend-ip); // jump literal sub block and its header
|
ip += ZSTD_decodeLiteralsBlock(g_dctxPtr, ip, iend-ip); // jump literal sub block and its header
|
||||||
g_cSize = iend-ip;
|
g_cSize = iend-ip;
|
||||||
memcpy(buff2, ip, g_cSize); // copy rest of block (starting with SeqHeader)
|
memcpy(buff2, ip, g_cSize); // copy rest of block (starting with SeqHeader)
|
||||||
|
|||||||
Reference in New Issue
Block a user