]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
key2any: free val if string is empty master
authorNikola Pajkovsky <nikolap@openssl.org>
Fri, 5 Dec 2025 10:00:22 +0000 (11:00 +0100)
committerNorbert Pocs <norbertp@openssl.org>
Mon, 8 Dec 2025 11:48:03 +0000 (12:48 +0100)
Resolves: https://scan5.scan.coverity.com/#/project-view/65138/10222?selectedIssue=1675327
Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29317)

providers/implementations/encode_decode/encode_key2any.c

index c9a718694d8d9becf3531e5afbbbdb104ac248ea..6122627d69d57ef96531700bd2443c2553c7e6dc 100644 (file)
@@ -1181,7 +1181,12 @@ static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[])
         if (!OSSL_PARAM_get_utf8_string(p.output_formats, &val, 0))
             return 0;
         OPENSSL_free(ctx->output_formats);
-        ctx->output_formats = *val != '\0' ? val : NULL;
+        if (*val != '\0') {
+            ctx->output_formats = val;
+        } else {
+            OPENSSL_free(val);
+            ctx->output_formats = NULL;
+        }
     }
 
     return 1;