From 29843ccf40f6e59021f4163e81885e85d258a0c1 Mon Sep 17 00:00:00 2001 From: olszomal Date: Fri, 20 Jan 2023 17:58:54 +0100 Subject: [PATCH] Fix resource leak, CID 1530764, 1530765 --- osslsigncode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osslsigncode.c b/osslsigncode.c index db6d69f..aacd4f9 100644 --- a/osslsigncode.c +++ b/osslsigncode.c @@ -1609,8 +1609,6 @@ static u_char *pe_calc_page_hash(char *indata, uint32_t header_size, } pphlen = 4 + EVP_MD_size(md); phlen = pphlen * (3 + (int)nsections + (int)(sigpos / pagesize)); - res = OPENSSL_malloc((size_t)phlen); - zeroes = OPENSSL_zalloc((size_t)pagesize); mdctx = EVP_MD_CTX_new(); if (!EVP_DigestInit(mdctx, md)) { @@ -1618,6 +1616,8 @@ static u_char *pe_calc_page_hash(char *indata, uint32_t header_size, printf("Unable to set up the digest context\n"); return NULL; /* FAILED */ } + res = OPENSSL_malloc((size_t)phlen); + zeroes = OPENSSL_zalloc((size_t)pagesize); EVP_DigestUpdate(mdctx, indata, header_size + 88); EVP_DigestUpdate(mdctx, indata + header_size + 92, 60 + pe32plus*16); EVP_DigestUpdate(mdctx, indata + header_size + 160 + pe32plus*16,