From 47f61b0ee9a8ed85e935941d2dd7a34e4e7a42d2 Mon Sep 17 00:00:00 2001
From: Nicolas Iooss <nicolas.iooss@m4x.org>
Date: Mon, 26 Dec 2016 22:18:31 +0100
Subject: [PATCH] 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>
---
 checkpolicy/queue.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/checkpolicy/queue.c b/checkpolicy/queue.c
index 272079c0..acc991c6 100644
--- a/checkpolicy/queue.c
+++ b/checkpolicy/queue.c
@@ -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);