From ab75df21ed9ab71a521f5d7f43f9e31f3f064d24 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Fri, 9 Feb 2018 05:12:13 -0800 Subject: [PATCH] fixed mono-symbol distribution --- lib/decompress/zstd_decompress.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index 0181351b..bc0e3fb3 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -734,7 +734,7 @@ static const FSE_decode_t4 OF_defaultDTable[(1<nbBits = 0; cell->nextState = 0; - cell->nbAdditionalBits = 0; - cell->baseValue = symbolValue; + assert(nbAddBits < 255); + cell->nbAdditionalBits = (BYTE)nbAddBits; + cell->baseValue = baseValue; } @@ -828,12 +829,15 @@ static size_t ZSTD_buildSeqTable(ZSTD_seqSymbol* DTableSpace, const ZSTD_seqSymb case set_rle : if (!srcSize) return ERROR(srcSize_wrong); if ( (*(const BYTE*)src) > max) return ERROR(corruption_detected); - ZSTD_buildSeqTable_rle(DTableSpace, *(const BYTE*)src); + { U32 const symbol = *(const BYTE*)src; + U32 const baseline = baseValue[symbol]; + U32 const nbBits = nbAdditionalBits[symbol]; + ZSTD_buildSeqTable_rle(DTableSpace, baseline, nbBits); + } *DTablePtr = DTableSpace; return 1; case set_basic : - assert(0); /* need to rebuild all default tables */ - //*DTablePtr = &defaultTable->dtable; + //*DTablePtr = &defaultTable->dtable; // when default tables will be pre-built ZSTD_buildFSETable(DTableSpace, defaultNorm, max, baseValue, nbAdditionalBits, defaultLog); *DTablePtr = DTableSpace; return 0;