diff options
author | JSDurand <mmemmew@gmail.com> | 2023-07-15 10:57:06 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-07-15 10:59:48 +0800 |
commit | 6a24e0a805c597b8f835c5c72a0e4dcdd64ca39b (patch) | |
tree | 88d5261151a796a7326a75073e4924e1853d4a0e /src/test.c | |
parent | 1d32e421927346d973487c01208ec955f8c68334 (diff) |
test.c: I forgot to check if a malloc fails.
* src/test.c: input is a malloc'ed pointer, which can be NULL due to
malloc not being able to allocate enough memory. So I have to guard
against this possibility.
Aside: Why are some intermediate files added again?
Diffstat (limited to 'src/test.c')
-rw-r--r-- | src/test.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -40,6 +40,14 @@ main(int argc, char **argv) } unsigned char *input = malloc (sizeof(unsigned char) * 16); + + if (input == NULL) { + clean_parser(parser); + clean_signed(&error_vec, 4); + printf("malloc fails at %s:%d\n", __FILE__, __LINE__); + + return EXIT_FAILURE; + } for (int i = 0; i < 16; i++) *(input+i) = 0; |