]> granicus.if.org Git - p11-kit/commitdiff
modules: Fix memleak when loading remote module
authorDaiki Ueno <dueno@redhat.com>
Wed, 21 Sep 2016 13:30:55 +0000 (15:30 +0200)
committerDaiki Ueno <ueno@gnu.org>
Mon, 31 Oct 2016 11:59:17 +0000 (12:59 +0100)
Make sure to call p11_virtual_uninit() on managed module.  Otherwise the
associated lower_module will not be released.

GCC's asan spotted this:
  Direct leak of 56 byte(s) in 1 object(s) allocated from:
      #0 0x7f6c5368dfe0 in calloc (/lib64/libasan.so.3+0xc6fe0)
      #1 0x4436ba in p11_rpc_client_init ../p11-kit/rpc-client.c:2082
      #2 0x42c147 in p11_rpc_transport_new ../p11-kit/rpc-transport.c:850
      #3 0x415d95 in setup_module_for_remote_inlock ../p11-kit/modules.c:411

p11-kit/modules.c

index 6e15c1d1872493a37c054406372ac34d4b146d0b..4af2a83d61444bb3f884228312d0235df32ef15b 100644 (file)
@@ -251,6 +251,8 @@ free_module_unlocked (void *data)
                assert (mod->initialize_thread == 0);
        }
 
+       p11_virtual_uninit (&mod->virt);
+
        if (mod->loaded_destroy)
                mod->loaded_destroy (mod->loaded_module);