From 3f474435ccca055f7f845db2ac03f5504ab9191f Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 2 Dec 2012 13:17:16 +0100 Subject: [PATCH] isl_test.c: test_ast: avoid invalid access on error Signed-off-by: Sven Verdoolaege --- isl_test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/isl_test.c b/isl_test.c index 485d8b4f..f0aee84e 100644 --- a/isl_test.c +++ b/isl_test.c @@ -3418,10 +3418,12 @@ static int test_ast(isl_ctx *ctx) expr = isl_ast_expr_add(expr1, expr2); expr = isl_ast_expr_neg(expr); str = isl_ast_expr_to_str(expr); - ok = !strcmp(str, "-(A + B)"); + ok = str ? !strcmp(str, "-(A + B)") : -1; free(str); isl_ast_expr_free(expr); + if (ok < 0) + return -1; if (!ok) isl_die(ctx, isl_error_unknown, "isl_ast_expr printed incorrectly", return -1); @@ -3432,10 +3434,12 @@ static int test_ast(isl_ctx *ctx) expr3 = isl_ast_expr_from_id(isl_id_alloc(ctx, "C", NULL)); expr = isl_ast_expr_sub(expr3, expr); str = isl_ast_expr_to_str(expr); - ok = !strcmp(str, "C - (A + B)"); + ok = str ? !strcmp(str, "C - (A + B)") : -1; free(str); isl_ast_expr_free(expr); + if (ok < 0) + return -1; if (!ok) isl_die(ctx, isl_error_unknown, "isl_ast_expr printed incorrectly", return -1); -- 2.11.4.GIT