coverity: fix 1484539 resource leak
authorPauli <pauli@openssl.org>
Mon, 10 May 2021 00:17:38 +0000 (10:17 +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/kdf.c

index 7b016051f1fdbcdedf8476a348f7a51792c88b60..c4892ed20ec44b2e57f3902b6a76e7c06d054983 100644 (file)
@@ -52,13 +52,14 @@ static char *alloc_kdf_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;