diff options
author | Daiki Ueno <dueno@redhat.com> | 2018-10-16 18:10:05 +0200 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2018-10-17 10:13:32 +0200 |
commit | b10dadce5a3c921149b2c9fe0dec614f8076ebda (patch) | |
tree | 1be6432a3cd602032c4c036bcfac4fea1b1f7158 /p11-kit | |
parent | c76197ddbbd0c29adc2bceff2ee9f740f71d134d (diff) |
build: Free memory before return{,_val}_if_* macros
Diffstat (limited to 'p11-kit')
-rw-r--r-- | p11-kit/iter.c | 5 | ||||
-rw-r--r-- | p11-kit/proxy.c | 10 |
2 files changed, 12 insertions, 3 deletions
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; |