Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SoftEtherVPN/libhamcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Shipitsin <chipitsine@gmail.com>2021-04-23 13:33:58 +0300
committerIlya Shipitsin <chipitsine@gmail.com>2021-04-23 13:33:58 +0300
commit69ae8017d308e56829afd86d6234b8d5e8b5a006 (patch)
tree2a079ea612b37723e3542266dff8ff822f598354
parentba137e665664221562427c4381d88ba6ad6e1e9a (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.c8
1 files changed, 8 insertions, 0 deletions
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)