delta: prevent possible null pointer use
authorPetr Štetiar <ynezz@true.cz>
Mon, 4 Nov 2019 23:39:46 +0000 (00:39 +0100)
committerPetr Štetiar <ynezz@true.cz>
Thu, 14 Nov 2019 16:11:34 +0000 (17:11 +0100)
scan-build from clang version 9 has reported following issue:

 delta.c:39:13: warning: Null pointer passed to 1st parameter expecting 'nonnull'
        int size = strlen(section) + 1;
                   ^~~~~~~~~~~~~~~

Signed-off-by: Petr Štetiar <ynezz@true.cz>
delta.c

diff --git a/delta.c b/delta.c
index a131e3a6ca9bba2927f1d6aee5c051bee3faed4d..d8bd3a6ccae8d0a6330c9660b3b5ee294cda1a3c 100644 (file)
--- a/delta.c
+++ b/delta.c
@@ -392,7 +392,7 @@ static void uci_filter_delta(struct uci_context *ctx, const char *name, const ch
                                match = false;
                }
 
-               if (!match) {
+               if (!match && ptr.section) {
                        uci_add_delta(ctx, &list, c,
                                ptr.section, ptr.option, ptr.value);
                }