From 324632171564a10c326200761043aa789f63e921 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 1 Jul 2015 16:08:48 +0200 Subject: [PATCH] isl_union_*_coalesce_entry: improve error handling In particular, only replace entry if coalescing was performed successfully. Signed-off-by: Sven Verdoolaege --- isl_union_templ.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/isl_union_templ.c b/isl_union_templ.c index 0c53599b..4de0aa8c 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -895,13 +895,21 @@ error: } #endif +/* Coalesce an entry in a UNION. Coalescing is performed in-place. + * Since the UNION may have several references, the entry is only + * replaced if the coalescing is successful. + */ static isl_stat FN(UNION,coalesce_entry)(void **entry, void *user) { - PART **part = (PART **) entry; + PART **part_p = (PART **) entry; + PART *part; - *part = FN(PART,coalesce)(*part); - if (!*part) + part = FN(PART,copy)(*part_p); + part = FN(PW,coalesce)(part); + if (!part) return isl_stat_error; + FN(PART,free)(*part_p); + *part_p = part; return isl_stat_ok; } -- 2.11.4.GIT