[OpenWrt-Devel] [PATCH uci 16/18] delta: prevent possible null pointer use

Petr Štetiar ynezz at true.cz
Mon Nov 4 19:36:55 EST 2019


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 at true.cz>
---
 delta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/delta.c b/delta.c
index 97bdd29d3005..228a328c21a1 100644
--- 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);
 		}

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list