My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix #4553

This is a bug in the streaming implementation of the v0.5 decoder.
The bug has always been there.
It requires an uncommon block configuration, which wasn't tested at the time.

v0.5 is deprecated now,
latest version to produce such format is v0.5.1 from February 2016.
It was superceded in April 2016.
So it's both short lived and very old.

Another PR will remove support of this format,
but it will still be possible to explicitely request this support on demand,
so better fix the issue.

+9 -2
+9 -2
vendor/git/zstd-c/lib/legacy/zstd_v05.c
··· 3972 3972 zbc->outStart += flushedSize; 3973 3973 if (flushedSize == toFlushSize) { 3974 3974 zbc->stage = ZBUFFv05ds_read; 3975 - if (zbc->outStart + BLOCKSIZE > zbc->outBuffSize) 3976 - zbc->outStart = zbc->outEnd = 0; 3975 + if (zbc->outStart + BLOCKSIZE > zbc->outBuffSize) { 3976 + /* Not enough room for next block - need to wrap buffer. 3977 + * Preserve history: copy the last windowSize bytes to the 3978 + * beginning so that back-references can still find valid data. */ 3979 + size_t const windowSize = (size_t)1 << zbc->params.windowLog; 3980 + size_t const preserveSize = MIN(zbc->outEnd, windowSize); 3981 + memmove(zbc->outBuff, zbc->outBuff + zbc->outEnd - preserveSize, preserveSize); 3982 + zbc->outStart = zbc->outEnd = preserveSize; 3983 + } 3977 3984 break; 3978 3985 } 3979 3986 /* cannot flush everything */