fix crash if no uci config file present
[oweals/mountd.git] / uci.c
diff --git a/uci.c b/uci.c
index f5aad020da387d5a19aee69faf63608a31aff4b2..46c392221b42bc9bc76981951ee8782ad758fd25 100644 (file)
--- a/uci.c
+++ b/uci.c
@@ -54,6 +54,9 @@ char* uci_get_option(struct uci_context *ctx, char *section, char *option)
        char *value = NULL;
        struct uci_ptr ptr;
 
+       if (!p)
+               return NULL;
+
        memset(&ptr, 0, sizeof(ptr));
        ptr.package = p->e.name;
        ptr.section = section;
@@ -101,6 +104,9 @@ void uci_for_each_section_type(char *type, void (*cb)(char*, void*), void *priv)
 {
        struct uci_element *e;
 
+       if (!p)
+               return;
+
        uci_foreach_element(&p->sections, e)
                if (!strcmp(type, uci_to_section(e)->type))
                        cb(e->name, priv);