aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepcompress.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-07-16 21:25:30 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-07-16 21:33:35 -0400
commit4988ba9a715870f5424460bb0354d003fe8a5bb8 (patch)
treee960ab68860568f6ae87a88dde8ac77ef21b07c7 /klippy/stepcompress.c
parent3fa7da804d1d558fa0a39262a5d13f859b6357fa (diff)
downloadkutter-4988ba9a715870f5424460bb0354d003fe8a5bb8.tar.gz
kutter-4988ba9a715870f5424460bb0354d003fe8a5bb8.tar.xz
kutter-4988ba9a715870f5424460bb0354d003fe8a5bb8.zip
stepcompress: Fix error causing queue to not be expanded in expand_queue()
The test to check if the queue only needed to be moved was not correct and it could lead to a segfault if clean_queue() was called instead of actually increasing the queue size. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/stepcompress.c')
-rw-r--r--klippy/stepcompress.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c
index 34b2a7d0..ca45a9b0 100644
--- a/klippy/stepcompress.c
+++ b/klippy/stepcompress.c
@@ -59,11 +59,11 @@ clean_queue(struct stepcompress *sc)
static void
expand_queue(struct stepcompress *sc, int count)
{
- if (sc->queue + count <= sc->queue_end) {
+ int alloc = sc->queue_end - sc->queue;
+ if (count + sc->queue_next - sc->queue_pos <= alloc) {
clean_queue(sc);
return;
}
- int alloc = sc->queue_end - sc->queue;
int pos = sc->queue_pos - sc->queue;
int next = sc->queue_next - sc->queue;
if (!alloc)