isl_map_union_disjoint: check spaces before handling special cases
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 24 Apr 2014 09:04:13 +0000 (24 11:04 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 24 Apr 2014 10:12:43 +0000 (24 12:12 +0200)
isl_map_union_disjoint checks for special cases such as inputs
that are empty before verifying that the two inputs live in the same space.
A result could therefore be produced even in some cases where the inputs
are invalid.
Check for equal spaces first and refuse to give a result if the input
spaces do not match.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_map.c

index 9014b2e..0bf21cf 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -7104,6 +7104,10 @@ static __isl_give isl_map *map_union_disjoint(__isl_take isl_map *map1,
        if (!map1 || !map2)
                goto error;
 
+       if (!isl_space_is_equal(map1->dim, map2->dim))
+               isl_die(isl_map_get_ctx(map1), isl_error_invalid,
+                       "spaces don't match", goto error);
+
        if (map1->n == 0) {
                isl_map_free(map1);
                return map2;
@@ -7129,8 +7133,6 @@ static __isl_give isl_map *map_union_disjoint(__isl_take isl_map *map1,
                return map2;
        }
 
-       isl_assert(map1->ctx, isl_space_is_equal(map1->dim, map2->dim), goto error);
-
        if (ISL_F_ISSET(map1, ISL_MAP_DISJOINT) &&
            ISL_F_ISSET(map2, ISL_MAP_DISJOINT))
                ISL_FL_SET(flags, ISL_MAP_DISJOINT);