diff options
author | Richard Levitte <levitte@openssl.org> | 2017-07-04 17:18:31 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2017-07-04 18:00:09 +0200 |
commit | 59099d6b8a3aec77f7d9f310ebf8e31b09c2d518 (patch) | |
tree | db5e70aaf78e30e808e547018275df611bb79f07 /crypto/store | |
parent | 43a0449fe6ce18b750803be8a115a412a7235496 (diff) |
STORE: fix possible memory leak
If scheme is NULL, the allocated res is leaked
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3841)
Diffstat (limited to 'crypto/store')
-rw-r--r-- | crypto/store/store_register.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crypto/store/store_register.c b/crypto/store/store_register.c index 7af1925f23..b366b19958 100644 --- a/crypto/store/store_register.c +++ b/crypto/store/store_register.c @@ -30,12 +30,7 @@ DEFINE_RUN_ONCE_STATIC(do_registry_init) OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme) { - OSSL_STORE_LOADER *res = OPENSSL_zalloc(sizeof(*res)); - - if (res == NULL) { - OSSL_STOREerr(OSSL_STORE_F_OSSL_STORE_LOADER_NEW, ERR_R_MALLOC_FAILURE); - return NULL; - } + OSSL_STORE_LOADER *res = NULL; /* * We usually don't check NULL arguments. For loaders, though, the @@ -49,6 +44,11 @@ OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme) return NULL; } + if ((res = OPENSSL_zalloc(sizeof(*res))) == NULL) { + OSSL_STOREerr(OSSL_STORE_F_OSSL_STORE_LOADER_NEW, ERR_R_MALLOC_FAILURE); + return NULL; + } + res->engine = e; res->scheme = scheme; return res; |