[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] warnings: address -Wnull-dereference in reader.c

From: David Michael
Subject: [PATCH] warnings: address -Wnull-dereference in reader.c
Date: Sun, 08 Jul 2018 14:08:02 -0400

This corrects a build failure when using GCC8 and configured with
the --enable-gcc-warnings and --enable-assert options:

src/reader.c: In function 'reader':
src/reader.c:740:17: error: potential null pointer dereference 
            node = node->next)

* src/reader.c (check_and_convert_grammar): Add a NULL assertion.

Signed-off-by: David Michael <address@hidden>


I'm hitting a build failure with the developer configure options
--enable-assert and --enable-gcc-warnings and GCC 8.  This patch will
correct it by adding another assert inside the loop to be consistent
with how it's handled after it, but note that it will still fail if
asserts are disabled and warnings are enabled.  If that case should be
supported, both aver() calls need to be replaced.



 src/reader.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/reader.c b/src/reader.c
index c220d707..c8b5c187 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -743,6 +743,7 @@ check_and_convert_grammar (void)
                node != NULL && node->content.sym != NULL;
                node = node->next)
+          aver (node != NULL);
       aver (node != NULL);
       grammar_start_symbol_set (node->content.sym,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]