bernstein_coefficients_cell: handle NULL poly
[platform/upstream/isl.git] / isl_bernstein.c
index 3ba18b4..7358b71 100644 (file)
@@ -13,6 +13,7 @@
  * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
  */
 
+#include <isl_ctx_private.h>
 #include <isl_map_private.h>
 #include <isl/set.h>
 #include <isl/seq.h>
@@ -92,7 +93,7 @@ error:
  */
 static int is_tight(int *k, int n, int d, isl_cell *cell)
 {
-       int i, j;
+       int i;
 
        for (i = 0; i < n; ++i) {
                int v;
@@ -254,6 +255,9 @@ static int bernstein_coefficients_cell(__isl_take isl_cell *cell, void *user)
        isl_set *dom;
        isl_ctx *ctx;
 
+       if (!poly)
+               goto error;
+
        nvar = isl_qpolynomial_dim(poly, isl_dim_set) - 1;
        n_vertices = cell->n_vertices;
 
@@ -262,8 +266,7 @@ static int bernstein_coefficients_cell(__isl_take isl_cell *cell, void *user)
                return isl_cell_foreach_simplex(cell,
                                            &bernstein_coefficients_cell, user);
 
-       subs = isl_alloc_array(data->poly->dim->ctx, isl_qpolynomial *,
-                               1 + nvar);
+       subs = isl_alloc_array(ctx, isl_qpolynomial *, 1 + nvar);
        if (!subs)
                goto error;