stepcompress: Eliminate possible infinite loop in compress_bisect_add()
Commit 47f30331
converted compress_bisect_add() to use "best reach"
instead of "best add". However, that change caused
compress_bisect_add() to behave poorly when passed in invalid data
(negative times). Change the code to better handle invalid data.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
9faa0fbd25
commit
9fa0a62c8a
|
@ -142,7 +142,7 @@ compress_bisect_add(struct stepcompress *sc)
|
||||||
struct points point = minmax_point(sc, sc->queue_pos);
|
struct points point = minmax_point(sc, sc->queue_pos);
|
||||||
int32_t outer_mininterval = point.minp, outer_maxinterval = point.maxp;
|
int32_t outer_mininterval = point.minp, outer_maxinterval = point.maxp;
|
||||||
int32_t add = 0, minadd = -0x8001, maxadd = 0x8000;
|
int32_t add = 0, minadd = -0x8001, maxadd = 0x8000;
|
||||||
int32_t bestinterval = 0, bestcount = 0, bestadd = 0, bestreach = 0;
|
int32_t bestinterval = 0, bestcount = 1, bestadd = 0, bestreach = INT32_MIN;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// Find longest valid sequence with the given 'add'
|
// Find longest valid sequence with the given 'add'
|
||||||
|
|
Loading…
Reference in New Issue