aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-10-08 20:28:43 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-10-10 11:31:56 -0400
commit9fa0a62c8a0990178aa2f0485d48ee7aaf975e7a (patch)
treec0b06d84526ccf92b5c2159c1f5d5cb634aa95fe
parent9faa0fbd25b948fc5fd7144a68ad03803d61784e (diff)
downloadkutter-9fa0a62c8a0990178aa2f0485d48ee7aaf975e7a.tar.gz
kutter-9fa0a62c8a0990178aa2f0485d48ee7aaf975e7a.tar.xz
kutter-9fa0a62c8a0990178aa2f0485d48ee7aaf975e7a.zip
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>
-rw-r--r--klippy/stepcompress.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c
index 584bde04..55cb09e8 100644
--- a/klippy/stepcompress.c
+++ b/klippy/stepcompress.c
@@ -142,7 +142,7 @@ compress_bisect_add(struct stepcompress *sc)
struct points point = minmax_point(sc, sc->queue_pos);
int32_t outer_mininterval = point.minp, outer_maxinterval = point.maxp;
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 (;;) {
// Find longest valid sequence with the given 'add'