From eea1e27c2b49d7604df939aeefaa7f45a5519fc8 Mon Sep 17 00:00:00 2001 From: Vitaly Chikunov Date: Sun, 9 Jan 2022 02:34:57 +0300 Subject: [PATCH] gost_prov: Avoid access to unallocated memory This should fix Coverity warning: *** CID 345245: (UNINIT) /gost_prov.c: 71 in provider_ctx_new() 65 && populate_gost_engine(ctx->e)) { 66 ctx->core_handle = core; 67 68 /* Ugly hack */ 69 err_handle = ctx->proverr_handle; 70 } else { >>> CID 345245: (UNINIT) >>> Using uninitialized value "ctx->e" when calling "provider_ctx_free". 71 provider_ctx_free(ctx); 72 ctx = NULL; 73 } 74 return ctx; 75 } Signed-off-by: Vitaly Chikunov Issue: #380 --- gost_prov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gost_prov.c b/gost_prov.c index b4de15f..3d23765 100644 --- a/gost_prov.c +++ b/gost_prov.c @@ -58,7 +58,7 @@ static PROV_CTX *provider_ctx_new(const OSSL_CORE_HANDLE *core, { PROV_CTX *ctx; - if ((ctx = malloc(sizeof(*ctx))) != NULL + if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) != NULL && (ctx->proverr_handle = proverr_new_handle(core, in)) != NULL && (ctx->libctx = OSSL_LIB_CTX_new()) != NULL && (ctx->e = ENGINE_new()) != NULL -- 2.39.5