From 0a618df059d93bf7fe9e3ec92e04db8bc1eeff07 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 9 May 2016 17:44:26 +0100 Subject: 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 --- crypto/objects/o_names.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crypto/objects') 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) -- cgit v1.2.3