From: Daiki Ueno Date: Wed, 21 Sep 2016 13:30:55 +0000 (+0200) Subject: modules: Fix memleak when loading remote module X-Git-Tag: 0.23.3~32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae0527969dbb2dea5bf97257c92a65b72ba71db5;p=p11-kit modules: Fix memleak when loading remote module 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 --- diff --git a/p11-kit/modules.c b/p11-kit/modules.c index 6e15c1d..4af2a83 100644 --- a/p11-kit/modules.c +++ b/p11-kit/modules.c @@ -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);