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:09:56 +0100 |
commit | 0a618df059d93bf7fe9e3ec92e04db8bc1eeff07 (patch) | |
tree | 8b1dd564d29c3847c8f5122f8af8288b8dc24cac /crypto/objects | |
parent | 308ff28673ae1a4a1b346761224b4a8851d41f58 (diff) | |
download | openssl-0a618df059d93bf7fe9e3ec92e04db8bc1eeff07.tar.gz |
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>
Diffstat (limited to 'crypto/objects')
-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 e43fb30a76..c655a908dd 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 = OPENSSL_malloc(sizeof(*onp)); 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) |