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>
This commit is contained in:
Kevin O'Connor 2016-11-29 13:00:08 -05:00
parent f547cab710
commit 4d6830a373
1 changed files with 2 additions and 2 deletions

View File

@ -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);