diff options
author | Benny Baumann <BenBE@geshi.org> | 2020-10-02 01:06:12 +0200 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-10-07 08:55:49 +1000 |
commit | a21db568bf3d0ab4194fd3e0917ee982f1fc8bfd (patch) | |
tree | 5328a63c88fb7d46931ba9c5a00b2b3e1b0e8363 /apps/cms.c | |
parent | 8ad369171fc2b435c0ca427111481da4d4c3c1ce (diff) |
Avoid memory leak of parent on allocation failure for child structure
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13055)
Diffstat (limited to 'apps/cms.c')
-rw-r--r-- | apps/cms.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/cms.c b/apps/cms.c index 9312c37fc2..91d951980d 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -647,9 +647,11 @@ int cms_main(int argc, char **argv) if (key_param == NULL || key_param->idx != keyidx) { cms_key_param *nparam; nparam = app_malloc(sizeof(*nparam), "key param buffer"); - nparam->idx = keyidx; - if ((nparam->param = sk_OPENSSL_STRING_new_null()) == NULL) + if ((nparam->param = sk_OPENSSL_STRING_new_null()) == NULL) { + OPENSSL_free(nparam); goto end; + } + nparam->idx = keyidx; nparam->next = NULL; if (key_first == NULL) key_first = nparam; |