diff options
author | Nathan Moinvaziri <nathan@solidstatenetworks.com> | 2020-09-28 16:43:50 -0700 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2020-10-09 11:19:29 +0200 |
commit | 982fc994018c00b323edb33c31ad666724523a20 (patch) | |
tree | 582bebdf476cba9fd4ea5a626151a6eb43808c6b /test/example.c | |
parent | 48d4bc5dfab855290a2dee34e74868655ed8fe6d (diff) |
Fixed dereference of possibly null head variable in test_deflate_set_header.
example.c:920:16: warning: dereference of possibly-NULL ‘head’ [CWE-690] [-Wanalyzer-possible-null-dereference]
920 | head->text = 1;
| ~~~~~~~~~~~^~~
‘test_deflate_set_header’: event 1
|
| 906 | PREFIX(gz_header) *head = calloc(1, sizeof(PREFIX(gz_header)));
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (1) this call could return NULL
Diffstat (limited to 'test/example.c')
-rw-r--r-- | test/example.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/example.c b/test/example.c index 4010c91..97ca002 100644 --- a/test/example.c +++ b/test/example.c @@ -909,6 +909,11 @@ void test_deflate_set_header(unsigned char *compr, size_t comprLen) { size_t len = strlen(hello)+1; + if (head == NULL) { + printf("out of memory\n"); + exit(1); + } + c_stream.zalloc = zalloc; c_stream.zfree = zfree; c_stream.opaque = (voidpf)0; |