[linux] Port libzstd UBSAN fix
This commit is contained in:
@@ -1978,10 +1978,15 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx *ctx, const void *src, size_t src
|
||||
break; /* nothing found : store previous solution */
|
||||
}
|
||||
|
||||
/* NOTE:
|
||||
* start[-offset+ZSTD_REP_MOVE-1] is undefined behavior.
|
||||
* (-offset+ZSTD_REP_MOVE-1) is unsigned, and is added to start, which
|
||||
* overflows the pointer, which is undefined behavior.
|
||||
*/
|
||||
/* catch up */
|
||||
if (offset) {
|
||||
while ((start > anchor) && (start > base + offset - ZSTD_REP_MOVE) &&
|
||||
(start[-1] == start[-1 - offset + ZSTD_REP_MOVE])) /* only search for offset within prefix */
|
||||
(start[-1] == (start-offset+ZSTD_REP_MOVE)[-1])) /* only search for offset within prefix */
|
||||
{
|
||||
start--;
|
||||
matchLength++;
|
||||
|
||||
Reference in New Issue
Block a user