diff options
author | Matt Caswell <matt@openssl.org> | 2016-05-09 17:44:26 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-05-24 00:12:04 +0100 |
commit | 649af484c8a15ad916c101aba86c7529dac7eccb (patch) | |
tree | dc829ecb2df894d6cf2bc0d0dfbaa34e74f310f1 | |
parent | e117522e752478a1fbb87117e4660ee20b85acc2 (diff) |
Fix a mem leak on an error path in OBJ_NAME_add()
If lh_OBJ_NAME_insert() fails then the allocated |onp| value is leaked.
RT#2238
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 0a618df059d93bf7fe9e3ec92e04db8bc1eeff07)
-rw-r--r-- | crypto/objects/o_names.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index 24859926ac..f106905ffa 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -191,7 +191,7 @@ int OBJ_NAME_add(const char *name, int type, const char *data) onp = (OBJ_NAME *)OPENSSL_malloc(sizeof(OBJ_NAME)); if (onp == NULL) { /* ERROR */ - return (0); + return 0; } onp->name = name; @@ -216,10 +216,11 @@ int OBJ_NAME_add(const char *name, int type, const char *data) } else { if (lh_OBJ_NAME_error(names_lh)) { /* ERROR */ - return (0); + OPENSSL_free(onp); + return 0; } } - return (1); + return 1; } int OBJ_NAME_remove(const char *name, int type) |