isl_mat_scale_down: avoid trampling over aliased matrices
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 3 Jun 2011 17:20:00 +0000 (19:20 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 4 Jun 2011 11:05:34 +0000 (13:05 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_mat.c

index 90e981f..4e6315c 100644 (file)
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -1441,6 +1441,10 @@ __isl_give isl_mat *isl_mat_scale_down(__isl_take isl_mat *mat, isl_int m)
 {
        int i;
 
+       if (isl_int_is_one(m))
+               return mat;
+
+       mat = isl_mat_cow(mat);
        if (!mat)
                return NULL;