isl_map_simplify.c: remove_duplicate_divs: avoid NULL pointer dereference
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 25 Jun 2010 16:59:58 +0000 (18:59 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 26 Jun 2010 15:37:39 +0000 (17:37 +0200)
isl_map_simplify.c

index 25b8afe..18daf94 100644 (file)
@@ -645,13 +645,16 @@ static struct isl_basic_map *remove_duplicate_divs(
        int k, l, h;
        int bits;
        struct isl_blk eq;
-       unsigned total_var = isl_dim_total(bmap->dim);
-       unsigned total = total_var + bmap->n_div;
+       unsigned total_var;
+       unsigned total;
        struct isl_ctx *ctx;
 
-       if (bmap->n_div <= 1)
+       if (!bmap || bmap->n_div <= 1)
                return bmap;
 
+       total_var = isl_dim_total(bmap->dim);
+       total = total_var + bmap->n_div;
+
        ctx = bmap->ctx;
        for (k = bmap->n_div - 1; k >= 0; --k)
                if (!isl_int_is_zero(bmap->div[k][0]))