From 83e92c2f9575707083d8b0c70ef330e285d70836 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <dueno@redhat.com>
Date: Wed, 17 Oct 2018 09:53:46 +0200
Subject: [PATCH 12/36] trust: Check index->buckets is allocated on cleanup

---
 trust/index.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/trust/index.c b/trust/index.c
index 6a8e535..2d1da29 100644
--- a/trust/index.c
+++ b/trust/index.c
@@ -193,9 +193,11 @@ p11_index_free (p11_index *index)
 
 	p11_dict_free (index->objects);
 	p11_dict_free (index->changes);
-	for (i = 0; i < NUM_BUCKETS; i++)
-		free (index->buckets[i].elem);
-	free (index->buckets);
+	if (index->buckets) {
+		for (i = 0; i < NUM_BUCKETS; i++)
+			free (index->buckets[i].elem);
+		free (index->buckets);
+	}
 	free (index);
 }
 
-- 
2.19.1

