From b10dadce5a3c921149b2c9fe0dec614f8076ebda Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Tue, 16 Oct 2018 18:10:05 +0200 Subject: build: Free memory before return{,_val}_if_* macros --- p11-kit/iter.c | 5 ++++- p11-kit/proxy.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'p11-kit') diff --git a/p11-kit/iter.c b/p11-kit/iter.c index 0e4ca6e..d1ffd91 100644 --- a/p11-kit/iter.c +++ b/p11-kit/iter.c @@ -157,7 +157,10 @@ p11_kit_iter_new (P11KitUri *uri, return_val_if_fail (iter != NULL, NULL); iter->modules = p11_array_new (NULL); - return_val_if_fail (iter->modules != NULL, NULL); + if (iter->modules == NULL) { + p11_kit_iter_free (iter); + return_val_if_reached (NULL); + } iter->want_writable = !!(behavior & P11_KIT_ITER_WANT_WRITABLE); iter->preload_results = !(behavior & P11_KIT_ITER_BUSY_SESSIONS); diff --git a/p11-kit/proxy.c b/p11-kit/proxy.c index b7fb63d..abe7935 100644 --- a/p11-kit/proxy.c +++ b/p11-kit/proxy.c @@ -267,7 +267,10 @@ proxy_create (Proxy **res, CK_FUNCTION_LIST **loaded, py->forkid = p11_forkid; py->inited = modules_dup (loaded); - return_val_if_fail (py->inited != NULL, CKR_HOST_MEMORY); + if (py->inited == NULL) { + proxy_free (py, 0); + return_val_if_reached (CKR_HOST_MEMORY); + } rv = p11_kit_modules_initialize (py->inited, NULL); @@ -320,7 +323,10 @@ proxy_create (Proxy **res, CK_FUNCTION_LIST **loaded, } py->sessions = p11_dict_new (p11_dict_ulongptr_hash, p11_dict_ulongptr_equal, NULL, free); - return_val_if_fail (py->sessions != NULL, CKR_HOST_MEMORY); + if (py->sessions == NULL) { + proxy_free (py, 1); + return_val_if_reached (CKR_HOST_MEMORY); + } py->refs = 1; *res = py; -- cgit v1.1