]> granicus.if.org Git - p11-kit/commitdiff
client: Fix memleaks in the module
authorDaiki Ueno <dueno@redhat.com>
Mon, 26 Feb 2018 13:51:43 +0000 (14:51 +0100)
committerDaiki Ueno <ueno@gnu.org>
Tue, 27 Feb 2018 11:27:45 +0000 (12:27 +0100)
p11-kit/client.c

index 26b2e74410bbe8ae06e510e3696cf6e66c0acfd5..698a8c3b2d0bdbd28276af2769cb2e5c5bb71047 100644 (file)
@@ -186,14 +186,19 @@ C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list)
                state->rpc = p11_rpc_transport_new (&state->virt,
                                                    address,
                                                    "client");
-               if (!state->rpc)
+               if (!state->rpc) {
+                       free (state);
                        rv = CKR_GENERAL_ERROR;
+               }
        }
 
        if (rv == CKR_OK) {
-               module = p11_virtual_wrap (&state->virt, free);
-               if (!module)
+               module = p11_virtual_wrap (&state->virt, (p11_destroyer)p11_virtual_uninit);
+               if (!module) {
+                       p11_rpc_transport_free (state->rpc);
+                       free (state);
                        rv = CKR_GENERAL_ERROR;
+               }
        }
 
        if (rv == CKR_OK) {
@@ -222,5 +227,6 @@ p11_client_module_cleanup (void)
                next = state->next;
                p11_rpc_transport_free (state->rpc);
                p11_virtual_unwrap (state->wrapped);
+               free (state);
        }
 }