lexer: Fix use-after-free error in lex_source_get_lookahead().
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 26 Sep 2021 18:06:45 +0000 (11:06 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 26 Sep 2021 18:06:45 +0000 (11:06 -0700)
commita91180ce13a1d95abed44b0c3cc12c94981bb5d6
tree2c22322e5ea62ddff6ab9652f4b74b2c8230ddcc
parent5d2044f51d79aa63799eb2a7cfc2937c7a4829cf
lexer: Fix use-after-free error in lex_source_get_lookahead().

This code used local variable 'out' as if its value stayed the same from
one iteration of the loop to the next, but in fact its scope meant that
it became indeterminate on each new iteration.  This commit fixes the
problem by moving its declaration to an outer scope.

Thanks to John Darrington for reporting the problem.
src/language/lexer/lexer.c