isl_union_map_alloc: plug memory leak on error path

Signed-off-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_hash_table_foreach: improve error handling

If the construction of an isl_union_map fails, then isl_union_map_free
may be called on a partially constructed isl_union_map.
This function in turn calls isl_hash_table_foreach, which therefore
needs to check if the table has been fully constructed.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_tab_add_sample: return int instead of isl_tab *

In particular, return -1 on error rather than freeing the input isl_tab.

Since an isl_tab is not reference counted, there is no way for
extend_affine_hull to tell its callers that the isl_tab has already
been freed, possible resulting in double frees on errors
in isl_tab_add_sample.  Having isl_tab_add_sample return -1 instead
solves this problem.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_tab_pip.c: propagate_equalities: return indication of failure

If propagate_equalities fails, then it may have freed some data structures,
in which case the calling function should abort its computation.
Return an indication of success or failure to allow the caller
to abort.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_tab_pip.c: sol_for_free: handle NULL input

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_basic_set_dim_residue_class: avoid double free on error path

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_coalesce.c: ineq_status_in: improve error handling

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_coalesce.c: eq_status_in: improve error handling

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_map.c: basic_set_maximal_difference_at: avoid double free on error path

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_node_alloc_for: plug memory leak on error path

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_expr_free: improve error handling

isl_ast_expr_free may get called on a partially constructed object
if the construction itself fails.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_schedule.c: graph_free: improve error handling

graph_free may get called on a partially constructed object
if the construction itself fails.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_printer_to_str: avoid access to uninitialized data on failure

In particular, initialize all fields to zero such that isl_printer_free
would not read any uninitialized data when called on a partially
constructed object.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_coalesce.c: isl_map_coalesce: improve error handling

Previously we could have dereferenced a NULL pointer.

Signed-off-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_union_*_alloc: plug memory leak on error path

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_union_*_alloc: avoid double free on error path

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_map.c: greator: avoid double free on error path

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>