]> granicus.if.org Git - flex/commitdiff
scanner: fix default of yy_top_state()
authorjannick0 <jannick0@users.noreply.github.com>
Sun, 7 Jan 2018 20:34:32 +0000 (21:34 +0100)
committerWill Estes <westes575@gmail.com>
Tue, 13 Mar 2018 14:45:16 +0000 (10:45 -0400)
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

index 1043238cfceb4690b7a12070ba233e8f97d3a6d9..05729df9e0aa1d7730d56ed08b6cab8487898101 100644 (file)
@@ -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;
 }
 ]])