From: JiashengJiang Date: Tue, 22 Apr 2025 13:03:44 +0000 (-0400) Subject: apps/pkeyutl.c: Add OPENSSL_free() to avoid a memory leak X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0dc6ea55a13dbe27af234b5328527d0a31ae68eb;p=thirdparty%2Fopenssl.git apps/pkeyutl.c: Add OPENSSL_free() to avoid a memory leak If EVP_PKEY_CTX_ctrl_str() fails, the code jumps to 'end' label without freeing passwd, causing a memory leak. Fixes: 9d1bf5f7de ("Add option to read pkeyopts interactively") Signed-off-by: JiashengJiang Reviewed-by: Shane Lontis Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27470) --- diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c index 2d3fd631447..79ad4c6f29f 100644 --- a/apps/pkeyutl.c +++ b/apps/pkeyutl.c @@ -426,6 +426,7 @@ int pkeyutl_main(int argc, char **argv) if (EVP_PKEY_CTX_ctrl_str(ctx, opt, passwd) <= 0) { BIO_printf(bio_err, "%s: Can't set parameter \"%s\":\n", prog, opt); + OPENSSL_free(passwd); goto end; } OPENSSL_free(passwd);