isl_test.c: before_for: explicitly check that depth has not become negative
authorSven Verdoolaege <sven.verdoolaege@gmail.com>
Mon, 27 Jul 2020 15:46:40 +0000 (27 17:46 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Wed, 5 Aug 2020 18:17:37 +0000 (5 20:17 +0200)
Without this explicit check, some versions of gcc
complain that the subsequent call to snprintf may result in a truncation.

Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
isl_test.c

index f845369..4322b46 100644 (file)
@@ -9471,7 +9471,7 @@ static __isl_give isl_id *before_for(__isl_keep isl_ast_build *build,
        if (data->before >= 3)
                isl_die(ctx, isl_error_unknown,
                        "unexpected number of for nodes", return NULL);
-       if (data->depth >= 2)
+       if (data->depth < 0 || data->depth >= 2)
                isl_die(ctx, isl_error_unknown,
                        "unexpected depth", return NULL);