From 2db95a41539a2fcccc3898d2fe239711947b5a65 Mon Sep 17 00:00:00 2001 From: Sung-hun Kim Date: Tue, 29 Aug 2023 15:40:41 +0900 Subject: [PATCH] Fix a coverity issue This patch fixes a coverity issue [1]. Since 'ctx' is dereferenced in EVP_DigestInit_ex call, it should be NULL checked before calling this function. [1] http://10.113.139.115:8081/reports.htm#v19039/p11006/fileInstanceId=612233125&defectInstanceId=130271535&mergedDefectId=1706287 Change-Id: I0e1e8a7a775734649ecffe9d5adaf0bd71dac8a5 Signed-off-by: Sung-hun Kim --- src/crash-stack/crash-stack.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c index 9a7f518..b8b93c4 100644 --- a/src/crash-stack/crash-stack.c +++ b/src/crash-stack/crash-stack.c @@ -225,6 +225,11 @@ static void __print_hash(Callstack *callstack, json_object *jobj, struct addr_no EVP_MD_CTX *ctx = EVP_MD_CTX_create(); const EVP_MD *md = EVP_sha256(); + if (!ctx) { + _E("Unable to get EVP_MD_CTX object"); + return; + } + if (!EVP_DigestInit_ex(ctx, md, NULL)) { _E("Unable to initialize hashing module"); goto out; -- 2.7.4