checkpolicy: do not leak queue elements in queue_destroy()

Elements which are inserted into a queue_t object are either NULL (from
insert_separator()) or strings allocated with malloc() in insert_id().
They would be freed if there are still present in the queue when it is
destroyed. Otherwise the memory allocated for these elements would be
leaked.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
Nicolas Iooss 2016-12-26 22:18:31 +01:00 committed by James Carter
parent 6ef96094d3
commit 47f61b0ee9

View File

@ -113,6 +113,7 @@ void queue_destroy(queue_t q)
p = q->head;
while (p != NULL) {
free(p->element);
temp = p;
p = p->next;
free(temp);