]> git.ipfire.org Git - thirdparty/zstd.git/commit
[binary-tree] Fix underflow of nbCompares 2820/head
authorNick Terrell <terrelln@fb.com>
Fri, 8 Oct 2021 18:45:30 +0000 (11:45 -0700)
committerNick Terrell <terrelln@fb.com>
Fri, 8 Oct 2021 20:22:55 +0000 (13:22 -0700)
commitc6c482fe07fb4f0e5007641ed9f6b758900c93c1
treef701ca80eeb74209fad254ee815234606849c8c3
parent52598d54e98d1de87a8e89c7fc0aa1bfc9b67e16
[binary-tree] Fix underflow of nbCompares

Fix underflow of `nbCompares` by switching to an `int` and comparing
`nbCompares > 0`. This is a minimal fix, because I don't want to change
the logic. These loops seem to be doing `nbCompares + 1` comparisons.

The bug was reported by Dan Carpenter and found by Smatch static
checker.

https://lore.kernel.org/all/20211008063704.GA5370@kili/
lib/compress/zstd_lazy.c
lib/compress/zstd_opt.c
tests/regression/results.csv