add a few missing null pointer checks, and fix check vs dereference order in some...
[project/uci.git] / ucimap.c
index 6a5c11721bbc79e192d22785e8ce1c7997bdc342..0bc31c58601dbee9bbbfdc75dde2dc65c70b8fea 100644 (file)
--- a/ucimap.c
+++ b/ucimap.c
@@ -295,6 +295,9 @@ realloc:
                offset = (items - (*list)->size) * sizeof(union ucimap_data);
 
        a->ptr = realloc(a->ptr, size);
                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;
        if (offset)
                memset((char *) a->ptr + offset, 0, size - offset);
        new = a->ptr;