Fix a coverity issue 56/297956/1
authorSung-hun Kim <sfoon.kim@samsung.com>
Tue, 29 Aug 2023 06:40:41 +0000 (15:40 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Tue, 29 Aug 2023 06:40:41 +0000 (15:40 +0900)
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 <sfoon.kim@samsung.com>
src/crash-stack/crash-stack.c

index 9a7f518..b8b93c4 100644 (file)
@@ -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;