From 1515cee3a7f88b136511f2b97d6af3db8e38faad Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 21 Oct 2009 14:31:22 +0200 Subject: [PATCH] isl_basic_set_solve_ilp: fix handling of sets with equalities First, the input set should be protected from being modified, and second, the test for whether a solution is requested was wrong. --- isl_ilp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/isl_ilp.c b/isl_ilp.c index 3aa10bd..15110c1 100644 --- a/isl_ilp.c +++ b/isl_ilp.c @@ -250,6 +250,7 @@ static enum isl_lp_result solve_ilp_with_eq(struct isl_basic_set *bset, int max, struct isl_mat *T = NULL; struct isl_vec *v; + bset = isl_basic_set_copy(bset); dim = isl_basic_set_total_dim(bset); v = isl_vec_alloc(bset->ctx, 1 + dim); if (!v) @@ -261,12 +262,13 @@ static enum isl_lp_result solve_ilp_with_eq(struct isl_basic_set *bset, int max, goto error; res = isl_basic_set_solve_ilp(bset, max, v->el, opt, sol_p); isl_vec_free(v); - if (res == isl_lp_ok && *sol_p) { + if (res == isl_lp_ok && sol_p) { *sol_p = isl_mat_vec_product(T, *sol_p); if (!*sol_p) res = isl_lp_error; } else isl_mat_free(T); + isl_basic_set_free(bset); return res; error: isl_mat_free(T); -- 2.7.4