parse: remove a check that is always true (due to unsigned data type)
[project/uci.git] / ucimap.c
index 6a5c117..b4f9518 100644 (file)
--- a/ucimap.c
+++ b/ucimap.c
@@ -13,7 +13,7 @@
  */
 
 /*
- * This file contains ucimap, an API for mapping UCI to C data structures 
+ * This file contains ucimap, an API for mapping UCI to C data structures
  */
 
 #include <strings.h>
@@ -295,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;
@@ -311,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;
@@ -709,8 +713,8 @@ ucimap_parse_section(struct uci_map *map, struct uci_sectionmap *sm, struct ucim
        return 0;
 
 error_mem:
-       if (sd->allocmap)
-               free(sd->allocmap);
+       free(sd->alloc_custom);
+       free(sd->allocmap);
        free(sd);
        return UCI_ERR_MEM;