From 67b3e448727da3093cdc6f0ca7fd151fbf3c10ad Mon Sep 17 00:00:00 2001 From: jannick0 Date: Sun, 7 Jan 2018 21:34:32 +0100 Subject: [PATCH] scanner: fix default of yy_top_state() For an _empty_ state stack the top of the state stack defaults to the state as if no state stack were present. NB: sanity check for `yy_start_stack_ptr` could be added in `yy_top_state()`. --- src/flex.skl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flex.skl b/src/flex.skl index 1043238..05729df 100644 --- a/src/flex.skl +++ b/src/flex.skl @@ -2465,7 +2465,7 @@ m4_ifdef( [[M4_YY_NO_TOP_STATE]],, %endif { M4_YY_DECL_GUTS_VAR(); - return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1]; + return yy_start_stack_ptr > 0 ? YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1] : YY_START; } ]]) -- 1.8.3.1