X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=ucimap.c;h=776a30439ef2ac9839e3cd5d6f5e25c4bdfb2e99;hp=16ce56ad56f95b285dae58ed579928d1d58f7f98;hb=2fcc6d756f23b439d24eb061ccd0a815a5626f69;hpb=2b86a11e49aa14d24c1e85ff5a7bd5ce58565df6 diff --git a/ucimap.c b/ucimap.c index 16ce56a..776a304 100644 --- a/ucimap.c +++ b/ucimap.c @@ -275,6 +275,8 @@ ucimap_resize_list(struct ucimap_section_data *sd, struct ucimap_list **list, in if (!*list) { new = calloc(1, size); + if (!new) + return -ENOMEM; ucimap_add_alloc(sd, new); goto set; @@ -293,6 +295,9 @@ realloc: offset = (items - (*list)->size) * sizeof(union ucimap_data); a->ptr = realloc(a->ptr, size); + if (!a->ptr) + return -ENOMEM; + if (offset) memset((char *) a->ptr + offset, 0, size - offset); new = a->ptr; @@ -309,6 +314,7 @@ ucimap_add_fixup(struct ucimap_section_data *sd, union ucimap_data *data, struct struct ucimap_fixup *f, tmp; struct uci_map *map = sd->map; + tmp.next = NULL; tmp.sm = om->data.sm; tmp.name = str; tmp.type = om->type; @@ -707,6 +713,8 @@ ucimap_parse_section(struct uci_map *map, struct uci_sectionmap *sm, struct ucim return 0; error_mem: + if (sd->alloc_custom) + free(sd->alloc_custom); if (sd->allocmap) free(sd->allocmap); free(sd);