timhughes / rpms / opensc

Forked from rpms/opensc 5 years ago
Clone
Blob Blame History Raw
From 6d02503e19680a9f3f4e556e4cd99b1c2bbf6d1a Mon Sep 17 00:00:00 2001
From: Nikos Mavrogiannopoulos <nmav@redhat.com>
Date: Fri, 28 Feb 2014 16:17:37 +0100
Subject: [PATCH] Call dlclose() only when having a valid handle.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
---
 src/common/libpkcs11.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/common/libpkcs11.c b/src/common/libpkcs11.c
index f8c70a7..b22d16d 100644
--- a/src/common/libpkcs11.c
+++ b/src/common/libpkcs11.c
@@ -74,7 +74,7 @@ C_UnloadModule(void *module)
 	if (!mod || mod->_magic != MAGIC)
 		return CKR_ARGUMENTS_BAD;
 
-	if (sc_dlclose(mod->handle) < 0)
+	if (mod->handle != NULL && sc_dlclose(mod->handle) < 0)
 		return CKR_FUNCTION_FAILED;
 
 	memset(mod, 0, sizeof(*mod));
-- 
1.8.5.3