From 793cc3b78f17bb5a3c151eba1144b73a5d51be3e Mon Sep 17 00:00:00 2001
From: Simon Haggett <simon.haggett@gmail.com>
Date: Tue, 12 Mar 2019 11:26:20 +0000
Subject: [PATCH 36/36] modules: Fix index used in call to p11_dict_remove()

This fixes a call to p11_dict_remove() in managed_steal_sessions_inlock() to use
the correct index in the stolen array (i, rather than at). This avoids an
assert, which was encountered on a host serving a PKCS#11 module to a remote
Linux client.

Signed-off-by: Simon Haggett <simon.haggett@gmail.com>
---
 p11-kit/modules.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/p11-kit/modules.c b/p11-kit/modules.c
index 891ce4c..39e1fda 100644
--- a/p11-kit/modules.c
+++ b/p11-kit/modules.c
@@ -1647,7 +1647,7 @@ managed_steal_sessions_inlock (p11_dict *sessions,
 	/* Only removed some, go through and remove those */
 	} else {
 		for (i = 0; i < at; i++) {
-			if (!p11_dict_remove (sessions, stolen + at))
+			if (!p11_dict_remove (sessions, stolen + i))
 				assert_not_reached ();
 		}
 	}
-- 
2.19.1

