coverity: fix 1484540 resource leak
authorPauli <pauli@openssl.org>
Mon, 10 May 2021 00:18:07 +0000 (10:18 +1000)
committerPauli <pauli@openssl.org>
Wed, 12 May 2021 01:11:53 +0000 (11:11 +1000)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/15208)

apps/mac.c

index ca02a781e579707dce8303b04991140f993217e1..5f80ca22c7879ceee0eeb090437132dfbf73c8bb 100644 (file)
@@ -56,13 +56,14 @@ static char *alloc_mac_algorithm_name(STACK_OF(OPENSSL_STRING) **optp,
                                       const char *name, const char *arg)
 {
     size_t len = strlen(name) + strlen(arg) + 2;
-    char *res = app_malloc(len, "algorithm name");
+    char *res;
 
     if (*optp == NULL)
         *optp = sk_OPENSSL_STRING_new_null();
     if (*optp == NULL)
         return NULL;
 
+    res = app_malloc(len, "algorithm name");
     BIO_snprintf(res, len, "%s:%s", name, arg);
     if (sk_OPENSSL_STRING_push(*optp, res))
         return res;