[opt] Add asserts for corruption in ZSTD_updateTree()

dev
Nick Terrell 2019-06-21 15:22:29 -07:00
parent aeb86b109a
commit 95e2b430ea
1 changed files with 7 additions and 2 deletions

View File

@ -525,8 +525,13 @@ void ZSTD_updateTree_internal(
DEBUGLOG(6, "ZSTD_updateTree_internal, from %u to %u (dictMode:%u)", DEBUGLOG(6, "ZSTD_updateTree_internal, from %u to %u (dictMode:%u)",
idx, target, dictMode); idx, target, dictMode);
while(idx < target) while(idx < target) {
idx += ZSTD_insertBt1(ms, base+idx, iend, mls, dictMode == ZSTD_extDict); U32 const forward = ZSTD_insertBt1(ms, base+idx, iend, mls, dictMode == ZSTD_extDict);
assert(idx < (U32)(idx + forward));
idx += forward;
}
assert((size_t)(ip - base) <= (size_t)(U32)(-1));
assert((size_t)(iend - base) <= (size_t)(U32)(-1));
ms->nextToUpdate = target; ms->nextToUpdate = target;
} }