diff options
author | Ilya Shipitsin <chipitsine@gmail.com> | 2021-04-23 13:33:58 +0300 |
---|---|---|
committer | Ilya Shipitsin <chipitsine@gmail.com> | 2021-04-23 13:33:58 +0300 |
commit | 69ae8017d308e56829afd86d6234b8d5e8b5a006 (patch) | |
tree | 2a079ea612b37723e3542266dff8ff822f598354 | |
parent | ba137e665664221562427c4381d88ba6ad6e1e9a (diff) |
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.
-rw-r--r-- | Hamcore.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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) |