From e06009c33616d07a0687d0adbb5c59ec1c8965af Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 30 Aug 2011 21:18:58 +0200 Subject: Don't crash if p11_kit_registered_modules() called after failed init --- p11-kit/modules.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'p11-kit') 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)) { -- cgit v1.2.1