From: jannick0 Date: Sun, 7 Jan 2018 20:34:32 +0000 (+0100) Subject: scanner: fix default of yy_top_state() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67b3e448727da3093cdc6f0ca7fd151fbf3c10ad;p=flex 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()`. --- 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; } ]])