isl_basic_map_align_divs: fix potential invalid access
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 3 Mar 2012 12:55:54 +0000 (13:55 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Sep 2012 13:08:21 +0000 (15:08 +0200)
isl_basic_map_align_divs is currently only called on inputs that are
known not to be NULL, but since we check whether they are NULL anyway,
we might as well only access them after this test.

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

index 5c693b0..4233b46 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -7611,7 +7611,7 @@ struct isl_basic_map *isl_basic_map_align_divs(
                struct isl_basic_map *dst, struct isl_basic_map *src)
 {
        int i;
-       unsigned total = isl_space_dim(src->dim, isl_dim_all);
+       unsigned total;
 
        if (!dst || !src)
                goto error;
@@ -7628,6 +7628,7 @@ struct isl_basic_map *isl_basic_map_align_divs(
                        src->n_div, 0, 2 * src->n_div);
        if (!dst)
                return NULL;
+       total = isl_space_dim(src->dim, isl_dim_all);
        for (i = 0; i < src->n_div; ++i) {
                int j = find_div(dst, src, i);
                if (j < 0) {