Skip to content

Commit ac2ee91

Browse files
tkanteckmdcornu
authored andcommitted
mem_zero_detect_test: fix for issue reported by static code analysis
Signed-off-by: Tomasz Kantecki <[email protected]>
1 parent 5a00eae commit ac2ee91

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mem/mem_zero_detect_test.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,19 @@ int main(int argc, char *argv[])
7878
// Test to help memory checkers
7979
for (i = 1; i < 2345; i++) {
8080
uint8_t *newbuf = (uint8_t *) malloc(i);
81+
82+
if (newbuf == NULL) {
83+
printf("Fail alloc test - not enough memory\n");
84+
failures = -1;
85+
goto exit;
86+
}
8187
memset(newbuf, 0, i);
8288
failures = isal_zero_detect(newbuf, i);
89+
free(newbuf);
8390
if (failures) {
8491
printf("Fail alloc test\n");
85-
free(newbuf);
8692
goto exit;
8793
}
88-
free(newbuf);
8994
}
9095

9196
// Test small buffers

0 commit comments

Comments
 (0)