isl_equalities.c: parameter_compression_multi: avoid NULL pointer dereference
[platform/upstream/isl.git] / isl_equalities.c
index e09e1c6..60c5e94 100644 (file)
@@ -186,8 +186,12 @@ static struct isl_mat *parameter_compression_multi(
        A = isl_mat_left_hermite(A, 0, NULL, NULL);
        T = isl_mat_sub_alloc(A->ctx, A->row, 0, A->n_row, 0, A->n_row);
        T = isl_mat_lin_to_aff(T);
+       if (!T)
+               goto error;
        isl_int_set(T->row[0][0], D);
        T = isl_mat_right_inverse(T);
+       if (!T)
+               goto error;
        isl_assert(T->ctx, isl_int_is_one(T->row[0][0]), goto error);
        T = isl_mat_transpose(T);
        isl_mat_free(A);
@@ -249,7 +253,7 @@ error:
  * then we divide this row of A by the common factor, unless gcd(A_i) = 0.
  * In the later case, we simply drop the row (in both A and d).
  *
- * If there are no rows left in A, the G is the identity matrix. Otherwise,
+ * If there are no rows left in A, then G is the identity matrix. Otherwise,
  * for each row i, we now determine the lattice of integer vectors
  * that satisfies this row.  Let U_i be the unimodular extension of the
  * row A_i.  This unimodular extension exists because gcd(A_i) = 1.
@@ -372,12 +376,12 @@ error:
  *
  *             M x - c = 0
  *
- * this function computes unimodular transformation from a lower-dimensional
+ * this function computes unimodular transformation from a lower-dimensional
  * space to the original space that bijectively maps the integer points x'
  * in the lower-dimensional space to the integer points x in the original
  * space that satisfy the equalities.
  *
- * The input is given as a matrix B = [ -c M ] and the out is a
+ * The input is given as a matrix B = [ -c M ] and the output is a
  * matrix that maps [1 x'] to [1 x].
  * If T2 is not NULL, then *T2 is set to a matrix mapping [1 x] to [1 x'].
  *
@@ -400,7 +404,7 @@ error:
  *
  * If any of the c' is non-integer, then the original set has no
  * integer solutions (since the x' are a unimodular transformation
- * of the x).
+ * of the x) and a zero-column matrix is returned.
  * Otherwise, the transformation is given by
  *
  *             x = U1 H1^{-1} c + U2 x2'