X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=ucimap-example.c;h=18c3c1f05397bcb5137530226f817fbe373e1af9;hp=9b315d0a193bcccf51be4f94fe6240bd63b46961;hb=07d6fd66f6a20e35490bc8b55d26fdb389016120;hpb=c81b25ffd34632dc6ac56fe61faaf44eca822259;ds=sidebyside diff --git a/ucimap-example.c b/ucimap-example.c index 9b315d0..18c3c1f 100644 --- a/ucimap-example.c +++ b/ucimap-example.c @@ -56,7 +56,7 @@ network_parse_ip(void *section, struct uci_optmap *om, union ucimap_data *data, if (!target) return -1; - *data->data = target; + data->ptr = target; for (i = 0; i < 4; i++) target[i] = (char) tmp[i]; @@ -67,7 +67,7 @@ static int network_format_ip(void *section, struct uci_optmap *om, union ucimap_data *data, char **str) { static char buf[16]; - unsigned char *ip = (unsigned char *) data->data[0]; + unsigned char *ip = (unsigned char *) data->ptr; if (ip) { sprintf(buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); @@ -132,6 +132,8 @@ static struct ucimap_section_data * network_allocate(struct uci_map *map, struct uci_sectionmap *sm, struct uci_section *s) { struct uci_network *p = malloc(sizeof(struct uci_network)); + if (!p) + return NULL; memset(p, 0, sizeof(struct uci_network)); return &p->map; } @@ -244,6 +246,8 @@ int main(int argc, char **argv) INIT_LIST_HEAD(&ifs); ctx = uci_alloc_context(); + if (!ctx) + return -1; ucimap_init(&network_map); if ((argc >= 2) && !strcmp(argv[1], "-s")) {