Fix potential memory leak on failure of ecx_gen_init()

When ecx_gen_set_params() returns 0, it could have duplicated the memory
for the parameter OSSL_KDF_PARAM_PROPERTIES already in gctx->propq,
leading to a memory leak.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26015)
This commit is contained in:
Niels Dossche 2024-11-20 19:57:38 +01:00 committed by Tomas Mraz
parent d7e8f6f781
commit 98be2e8fb6

View File

@ -510,7 +510,7 @@ static void *ecx_gen_init(void *provctx, int selection,
#endif
}
if (!ecx_gen_set_params(gctx, params)) {
OPENSSL_free(gctx);
ecx_gen_cleanup(gctx);
gctx = NULL;
}
return gctx;