some extra null pointer checks
authorFelix Fietkau <nbd@openwrt.org>
Sun, 3 Feb 2008 02:05:03 +0000 (03:05 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 3 Feb 2008 02:05:03 +0000 (03:05 +0100)
cli.c
file.c

diff --git a/cli.c b/cli.c
index e14757e5a88cdfc13aadd74d82813715debab8b1..845fc2acee988e0ac285ba6d6e8f900d53549cf3 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -101,6 +101,8 @@ static int package_cmd(int cmd, char *package)
                cli_perror();
                return 1;
        }
+       if (!p)
+               return 0;
        switch(cmd) {
        case CMD_COMMIT:
                if (uci_commit(ctx, &p, false) != UCI_OK)
@@ -212,6 +214,8 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv)
                cli_perror();
                return 1;
        }
+       if (!p)
+               return 0;
 
        switch(cmd) {
        case CMD_GET:
diff --git a/file.c b/file.c
index 4b607f803aa283b8baa77caeb547f7a9fc65ca6d..416422d6182e08d0d5aa45f621b6a12bf2891ce2 100644 (file)
--- a/file.c
+++ b/file.c
@@ -453,6 +453,9 @@ static void uci_parse_line(struct uci_context *ctx, bool single)
                char *pbrk = NULL;
                word = strtok_r(word, " \t", &pbrk);
 
+               if (!word)
+                       continue;
+
                switch(word[0]) {
                        case '#':
                                return;