isl_mat_extend: make sure the number of rows never decreases
[platform/upstream/isl.git] / isl_mat.c
index c1ba26e..c96017e 100644 (file)
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -57,6 +57,8 @@ struct isl_mat *isl_mat_extend(struct isl_mat *mat,
        if (mat->max_col < n_col) {
                struct isl_mat *new_mat;
 
+               if (n_row < mat->n_row)
+                       n_row = mat->n_row;
                new_mat = isl_mat_alloc(mat->ctx, n_row, n_col);
                if (!new_mat)
                        goto error;