From 57d8f36a6cfbde5a9a783f11f2b75f19005c23e1 Mon Sep 17 00:00:00 2001
From: Stef Walter <stefw@gnome.org>
Date: Wed, 20 Mar 2013 20:59:26 +0100
Subject: Fix invalid memory accesses reported by 'make memcheck'

These are things that showed up in valgrind while running the tests.
---
 trust/index.c            | 2 +-
 trust/tests/test-index.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

(limited to 'trust')

diff --git a/trust/index.c b/trust/index.c
index 6e9a46c..1275cd9 100644
--- a/trust/index.c
+++ b/trust/index.c
@@ -648,7 +648,7 @@ index_select (p11_index *index,
 		for (j = 1; j < num; j++) {
 			assert (buckets[j]->elem); /* checked above */
 			at = binary_search (buckets[j]->elem, 0, buckets[j]->num, handle);
-			if (buckets[j]->elem[at] != handle) {
+			if (at >= buckets[j]->num || buckets[j]->elem[at] != handle) {
 				handle = 0;
 				break;
 			}
diff --git a/trust/tests/test-index.c b/trust/tests/test-index.c
index 3cda272..d58a510 100644
--- a/trust/tests/test-index.c
+++ b/trust/tests/test-index.c
@@ -539,6 +539,8 @@ test_find_all (CuTest *tc)
 	free (check);
 
 	/* A double check of this method */
+	one = 0UL;
+	check = &one;
 	CuAssertTrue (tc, !handles_are (check, 29292929, 0UL));
 	CuAssertTrue (tc, !handles_are (NULL, 0UL));
 
-- 
cgit v1.1