summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-08-30 21:18:58 +0200
committerStef Walter <stefw@collabora.co.uk>2011-08-30 21:18:58 +0200
commite06009c33616d07a0687d0adbb5c59ec1c8965af (patch)
treeca44d94943a0b23ebc754625dbcdef0ce9ab9eb2
parentfbdb10edfa39ada801af187dd3abaa5c8bf2ae6b (diff)
downloadp11-kit-e06009c33616d07a0687d0adbb5c59ec1c8965af.tar.gz
Don't crash if p11_kit_registered_modules() called after failed init
-rw-r--r--p11-kit/modules.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/p11-kit/modules.c b/p11-kit/modules.c
index 33101fa..e683c46 100644
--- a/p11-kit/modules.c
+++ b/p11-kit/modules.c
@@ -775,12 +775,13 @@ p11_kit_finalize_registered (void)
CK_FUNCTION_LIST_PTR_PTR
_p11_kit_registered_modules_unlocked (void)
{
- CK_FUNCTION_LIST_PTR_PTR result;
+ CK_FUNCTION_LIST_PTR_PTR result = NULL;
Module *mod;
hashiter iter;
int i = 0;
- result = calloc (hash_size (gl.modules) + 1, sizeof (CK_FUNCTION_LIST_PTR));
+ if (gl.modules)
+ result = calloc (hash_size (gl.modules) + 1, sizeof (CK_FUNCTION_LIST_PTR));
if (result) {
hash_iterate (gl.modules, &iter);
while (hash_next (&iter, NULL, (void **)&mod)) {