From 954884ce0859a7d1d23ca6a66808d6bf5763de43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ada=20Gottenstr=C3=A4ter?= Date: Wed, 11 Dec 2024 15:15:28 +0100 Subject: [PATCH] Fix segfault in CheckSimpleIncrementLoop --- loops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loops.c b/loops.c index fbfc7904b..07ea962b8 100644 --- a/loops.c +++ b/loops.c @@ -1050,12 +1050,13 @@ CheckSimpleIncrementLoop(AST *stmt) } /* check that the update is i++, and the variable is not used anywhere else */ - while (update->kind == AST_SEQUENCE) { + while (update && update->kind == AST_SEQUENCE) { if (AstUsesName(update->right, updateVar)) { return; } update = update->left; } + if (!update) return; if (update->kind != AST_OPERATOR || update->d.ival != K_INCREMENT) { return; }