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 e14757e..845fc2a 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -101,6 +101,8 @@ static int package_cmd(int cmd, char *package)
                cli_perror();
                return 1;
        }
                cli_perror();
                return 1;
        }
+       if (!p)
+               return 0;
        switch(cmd) {
        case CMD_COMMIT:
                if (uci_commit(ctx, &p, false) != UCI_OK)
        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;
        }
                cli_perror();
                return 1;
        }
+       if (!p)
+               return 0;
 
        switch(cmd) {
        case CMD_GET:
 
        switch(cmd) {
        case CMD_GET:
diff --git a/file.c b/file.c
index 4b607f8..416422d 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);
 
                char *pbrk = NULL;
                word = strtok_r(word, " \t", &pbrk);
 
+               if (!word)
+                       continue;
+
                switch(word[0]) {
                        case '#':
                                return;
                switch(word[0]) {
                        case '#':
                                return;