X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=cli.c;fp=cli.c;h=cfbf26171531bb5d35a6e0d74136c7d71d709da4;hp=b660273f96b397023e5f62ce3e45e329adeb1a0d;hb=ef95525edc1ade7e729187b011de889b8f5f57c6;hpb=2b86a11e49aa14d24c1e85ff5a7bd5ce58565df6 diff --git a/cli.c b/cli.c index b660273..cfbf261 100644 --- a/cli.c +++ b/cli.c @@ -98,6 +98,8 @@ uci_lookup_section_ref(struct uci_section *s) } if (!ti) { ti = malloc(sizeof(struct uci_type_list)); + if (!ti) + return NULL; memset(ti, 0, sizeof(struct uci_type_list)); ti->next = type_list; type_list = ti; @@ -110,8 +112,12 @@ uci_lookup_section_ref(struct uci_section *s) } else { typestr = realloc(typestr, maxlen); } - sprintf(typestr, "@%s[%d]", ti->name, ti->idx); + + if (typestr) + sprintf(typestr, "@%s[%d]", ti->name, ti->idx); + ti->idx++; + return typestr; }