isl_map_affine_hull: handle non-obviously empty input
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 10 Apr 2010 14:19:23 +0000 (16:19 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 10 Apr 2010 14:20:51 +0000 (16:20 +0200)
In particular, detect equalities before checking whether the input is empty.
Otherwise, we could be accessing the first element of an empty list.

isl_affine_hull.c

index ffae59c..02f1913 100644 (file)
@@ -932,6 +932,9 @@ struct isl_basic_map *isl_map_affine_hull(struct isl_map *map)
        struct isl_basic_map *hull = NULL;
        struct isl_set *set;
 
+       map = isl_map_detect_equalities(map);
+       map = isl_map_align_divs(map);
+
        if (!map)
                return NULL;
 
@@ -941,10 +944,6 @@ struct isl_basic_map *isl_map_affine_hull(struct isl_map *map)
                return hull;
        }
 
-       map = isl_map_detect_equalities(map);
-       map = isl_map_align_divs(map);
-       if (!map)
-               return NULL;
        model = isl_basic_map_copy(map->p[0]);
        set = isl_map_underlying_set(map);
        set = isl_set_cow(set);