aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/serialqueue.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-11-29 13:00:08 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-11-29 18:49:12 -0500
commit4d6830a3730048ded7cb6d50db834e5cef91f14f (patch)
treee2257c3ba82da2836408e47c24861b975fa27f63 /klippy/serialqueue.c
parentf547cab7109635e663585a0704eb3b06f194a2d0 (diff)
downloadkutter-4d6830a3730048ded7cb6d50db834e5cef91f14f.tar.gz
kutter-4d6830a3730048ded7cb6d50db834e5cef91f14f.tar.xz
kutter-4d6830a3730048ded7cb6d50db834e5cef91f14f.zip
serialqueue: Fix possible memory leak in serialqueue_extract_old()
Make sure to free all messages even if the requested size is smaller than the number of messages. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/serialqueue.c')
-rw-r--r--klippy/serialqueue.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/klippy/serialqueue.c b/klippy/serialqueue.c
index b3451ad6..444c5ea4 100644
--- a/klippy/serialqueue.c
+++ b/klippy/serialqueue.c
@@ -1034,10 +1034,10 @@ serialqueue_extract_old(struct serialqueue *sq, int sentq
// Walk the debug list
int pos = 0;
- while (!list_empty(&current) && pos < max) {
+ while (!list_empty(&current)) {
struct queue_message *qm = list_first_entry(
&current, struct queue_message, node);
- if (qm->len) {
+ if (qm->len && pos < max) {
struct pull_queue_message *pqm = q++;
pos++;
memcpy(pqm->msg, qm->msg, qm->len);