From: Nikola Pajkovsky Date: Fri, 5 Dec 2025 10:00:22 +0000 (+0100) Subject: key2any: free val if string is empty X-Git-Tag: 4.0-PRE-CLANG-FORMAT-WEBKIT~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13015c3f41ba33a6b247ee564dde0586043e7e4a;p=thirdparty%2Fopenssl.git key2any: free val if string is empty Resolves: https://scan5.scan.coverity.com/#/project-view/65138/10222?selectedIssue=1675327 Signed-off-by: Nikola Pajkovsky Reviewed-by: Tomas Mraz Reviewed-by: Viktor Dukhovni Reviewed-by: Tim Hudson (Merged from https://github.com/openssl/openssl/pull/29317) --- diff --git a/providers/implementations/encode_decode/encode_key2any.c b/providers/implementations/encode_decode/encode_key2any.c index c9a718694d8..6122627d69d 100644 --- a/providers/implementations/encode_decode/encode_key2any.c +++ b/providers/implementations/encode_decode/encode_key2any.c @@ -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;