diff options
author | Daiki Ueno <dueno@redhat.com> | 2018-08-22 13:47:03 +0200 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2018-08-28 15:07:45 +0200 |
commit | c1b565413dae632a4ab78cea08ed103d9418921b (patch) | |
tree | d98af8395b5ea01019902ce58be76d72485f3e3c /p11-kit | |
parent | 347a8793d23036433ab0ba39049f0e832bb05b3d (diff) |
virtual: Tighten error handling when fixed closures are exhausted
Diffstat (limited to 'p11-kit')
-rw-r--r-- | p11-kit/virtual.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/p11-kit/virtual.c b/p11-kit/virtual.c index a027368..6abfe7a 100644 --- a/p11-kit/virtual.c +++ b/p11-kit/virtual.c @@ -3059,13 +3059,17 @@ p11_virtual_wrap_fixed (p11_virtual *virt, if (fixed_closures[i] == NULL) { Wrapper *wrapper; wrapper = create_fixed_wrapper (virt, i, destroyer); - result = &wrapper->bound; - fixed_closures[i] = result; + if (wrapper) { + result = &wrapper->bound; + fixed_closures[i] = result; + } break; } } p11_mutex_unlock (&p11_virtual_mutex); + return_val_if_fail (result != NULL, NULL); + return result; } @@ -3084,7 +3088,7 @@ p11_virtual_unwrap_fixed (CK_FUNCTION_LIST_PTR module) p11_mutex_unlock (&p11_virtual_mutex); } -static bool +static void init_wrapper_funcs_fixed (Wrapper *wrapper, CK_FUNCTION_LIST *fixed) { const FunctionInfo *info; @@ -3119,8 +3123,6 @@ init_wrapper_funcs_fixed (Wrapper *wrapper, CK_FUNCTION_LIST *fixed) */ wrapper->bound.C_CancelFunction = short_C_CancelFunction; wrapper->bound.C_GetFunctionStatus = short_C_GetFunctionStatus; - - return true; } static Wrapper * @@ -3141,10 +3143,7 @@ create_fixed_wrapper (p11_virtual *virt, wrapper->bound.version.minor = CRYPTOKI_VERSION_MINOR; wrapper->fixed_index = index; - if (!init_wrapper_funcs_fixed (wrapper, &p11_virtual_fixed[index])) { - free (wrapper); - return NULL; - } + init_wrapper_funcs_fixed (wrapper, &p11_virtual_fixed[index]); assert ((void *)wrapper == (void *)&wrapper->bound); assert (p11_virtual_is_wrapper (&wrapper->bound)); |