From 69ae8017d308e56829afd86d6234b8d5e8b5a006 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Fri, 23 Apr 2021 15:33:58 +0500 Subject: Hamcore.c: add malloc failure check Hamcore.c 25 warn V575 The potential null pointer is passed into 'memset' function. Inspect the first argument. Check lines: 25, 24. Hamcore.c 57 warn V575 The potential null pointer is passed into 'memset' function. Inspect the first argument. Check lines: 57, 56. --- Hamcore.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Hamcore.c b/Hamcore.c index 3475312..04807f7 100644 --- a/Hamcore.c +++ b/Hamcore.c @@ -22,6 +22,10 @@ HAMCORE *HamcoreOpen(const char *path) } HAMCORE *hamcore = malloc(sizeof(HAMCORE)); + if (!hamcore) + { + return NULL; + } memset(hamcore, 0, sizeof(HAMCORE)); hamcore->File = FileOpen(path, false); @@ -54,6 +58,10 @@ HAMCORE *HamcoreOpen(const char *path) files->Num = BigEndian32(tmp); files->List = malloc(sizeof(HAMCORE_FILE) * files->Num); + if (!files->List) + { + return NULL; + } memset(files->List, 0, sizeof(HAMCORE_FILE) * files->Num); for (size_t i = 0; i < files->Num; ++i) -- cgit v1.2.3