From 8c1741939f2255115d03d1c694bfdfd7986050de Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 17 Apr 2014 23:09:30 +0200 Subject: [PATCH] drop isl_tab_extend in favor of isl_tab_extend_cons Since an isl_tab is not reference counted, there may be no way for callers of isl_tab_extend their callers that the isl_tab has already been freed, possible resulting in double frees on errors. isl_tab_extend is just a wrapper around isl_tab_extend_cons turning the appropriate interface of returning -1 on error into a bad interface of freeing the isl_tab and returning NULL. Move the single remaining call to isl_tab_extend to a call to isl_tab_extend_cons. This does not solve any problems in itself but should avoid future problems with isl_tab_extend. Signed-off-by: Sven Verdoolaege --- isl_map_simplify.c | 3 ++- isl_tab.c | 9 --------- isl_tab.h | 1 - 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/isl_map_simplify.c b/isl_map_simplify.c index 25f635fb..71d51d5d 100644 --- a/isl_map_simplify.c +++ b/isl_map_simplify.c @@ -1990,7 +1990,8 @@ static __isl_give isl_basic_set *uset_gist_full(__isl_take isl_basic_set *bset, for (i = 0; i < context_ineq; ++i) if (isl_tab_freeze_constraint(tab, i) < 0) goto error; - tab = isl_tab_extend(tab, bset->n_ineq); + if (isl_tab_extend_cons(tab, bset->n_ineq) < 0) + goto error; for (i = 0; i < bset->n_ineq; ++i) if (isl_tab_add_ineq(tab, bset->ineq[i]) < 0) goto error; diff --git a/isl_tab.c b/isl_tab.c index 0dcfc14c..91552103 100644 --- a/isl_tab.c +++ b/isl_tab.c @@ -172,15 +172,6 @@ int isl_tab_extend_vars(struct isl_tab *tab, unsigned n_new) return 0; } -struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new) -{ - if (isl_tab_extend_cons(tab, n_new) >= 0) - return tab; - - isl_tab_free(tab); - return NULL; -} - static void free_undo_record(struct isl_tab_undo *undo) { switch (undo->type) { diff --git a/isl_tab.h b/isl_tab.h index ff0f8c96..cfae0c91 100644 --- a/isl_tab.h +++ b/isl_tab.h @@ -205,7 +205,6 @@ enum isl_lp_result isl_tab_min(struct isl_tab *tab, isl_int *f, isl_int denom, isl_int *opt, isl_int *opt_denom, unsigned flags) WARN_UNUSED; -struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new) WARN_UNUSED; int isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq) WARN_UNUSED; int isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED; int isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED; -- 2.11.4.GIT