[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
null-dereference error on GCC 13
From: |
Pietro Monteiro |
Subject: |
null-dereference error on GCC 13 |
Date: |
Mon, 10 Jul 2023 15:39:47 -0400 |
User-agent: |
Cyrus-JMAP/3.9.0-alpha0-531-gfdfa13a06d-fm-20230703.001-gfdfa13a0 |
I'm building the tip of branch-1.4 (a886ea40a29a08954ff80772e267828a1d440cc9)
with GCC 13 and it fails with a null-dereference error on output.c:491:
output.c: In function 'make_room_for':
output.c:491:40: error: potential null pointer dereference
[-Werror=null-dereference]
491 | output_file = output_diversion->u.file;
| ~~~~~~~~~~~~~~~~~~~^~~~~
If I tell GCC to stop caring about null-dereference errors I get a
null-argument error on output.c:575:
$make CFLAGS="-Wno-error=null-dereference
snip...
output.c: In function 'output_text':
output.c:575:7: error: use of NULL where non-null expected [CWE-476]
[-Werror=analyzer-null-argument]
575 | memcpy (output_cursor, text, (size_t) length);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
snip...
In file included from ../lib/string.h:41,
from m4.h:35,
from output.c:22:
/usr/include/string.h:43:14: note: argument 1 of 'memcpy' must be non-null
43 | extern void *memcpy (void *__restrict __dest, const void *__restrict
__src,
| ^~~~~~
A simple NULL check on output_diversion at the start of make_room_for fixes
both issues:
diff --git a/src/output.c b/src/output.c
index 6dc8280a..4bdf872b 100644
--- a/src/output.c
+++ b/src/output.c
@@ -416,6 +416,10 @@ make_room_for (int length)
buffers start at 0 bytes, then 512, then keep doubling until it is
decided to flush them to disk. */
+ if (!output_diversion)
+ m4_failure (errno,
+ _("ERROR: diversion not initialized"));
+
output_diversion->used = output_diversion->size - output_unused;
for (wanted_size = output_diversion->size;
Thanks,
pietro
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- null-dereference error on GCC 13,
Pietro Monteiro <=