isl_space_drop_dims: take into account overflow when checking indices
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 6 Dec 2013 13:03:53 +0000 (6 14:03 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 19 Dec 2013 11:35:31 +0000 (19 12:35 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_space.c

index 864753f..aa8a09d 100644 (file)
@@ -1291,7 +1291,9 @@ __isl_give isl_space *isl_space_drop_dims(__isl_take isl_space *dim,
                isl_die(dim->ctx, isl_error_invalid,
                        "cannot drop dimensions of specified type", goto error);
 
-       isl_assert(dim->ctx, first + num <= n(dim, type), goto error);
+       if (first + num > n(dim, type) || first + num < first)
+               isl_die(isl_space_get_ctx(dim), isl_error_invalid,
+                       "index out of bounds", return isl_space_free(dim));
        dim = isl_space_cow(dim);
        if (!dim)
                goto error;