From f06b8712cea651b22c238afb01bc47fce6f1aff0 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 1 Mar 2012 11:25:22 +0100 Subject: [PATCH] isl_pw_*_on_shared_domain: improve error handling Signed-off-by: Sven Verdoolaege --- isl_pw_templ.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/isl_pw_templ.c b/isl_pw_templ.c index 65bdf46..ed19733 100644 --- a/isl_pw_templ.c +++ b/isl_pw_templ.c @@ -523,7 +523,7 @@ static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1, __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2)) { int i, j, n; - PW *res; + PW *res = NULL; if (!pw1 || !pw2) goto error; @@ -539,11 +539,16 @@ static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1, for (j = 0; j < pw2->n; ++j) { isl_set *common; EL *res_ij; + int empty; + common = isl_set_intersect( isl_set_copy(pw1->p[i].set), isl_set_copy(pw2->p[j].set)); - if (isl_set_plain_is_empty(common)) { + empty = isl_set_plain_is_empty(common); + if (empty < 0 || empty) { isl_set_free(common); + if (empty < 0) + goto error; continue; } @@ -560,6 +565,7 @@ static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1, error: FN(PW,free)(pw1); FN(PW,free)(pw2); + FN(PW,free)(res); return NULL; } -- 2.7.4