From 0faa8f0dbe445f41c8f61a9b578d567338dd93c6 Mon Sep 17 00:00:00 2001 From: Robert Gustafsson Date: Wed, 18 Oct 2017 12:42:05 +0200 Subject: Fix memory leak causing not appended values to be allocated --- broccoli/src/fifoqueue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/broccoli/src/fifoqueue.c b/broccoli/src/fifoqueue.c index 6a99740..f3d9272 100644 --- a/broccoli/src/fifoqueue.c +++ b/broccoli/src/fifoqueue.c @@ -47,6 +47,7 @@ add_to_queue(Fifo_q * q, Sensor_t * sensor) if(q == NULL){ printf("Error: Queue not initialized\n"); + free(sensor); //free if not appended return -1; } else if(is_full(q)){ @@ -55,6 +56,7 @@ add_to_queue(Fifo_q * q, Sensor_t * sensor) pop_from_queue(q); #endif q->droppedValues++; + free(sensor); //free if not appended return 0; } sem_wait(&q->lock); -- cgit v1.2.3