Skip to content

Commit

Permalink
FIX: lexer corrupting memory or crashing on LOAD event after failing …
Browse files Browse the repository at this point in the history
…to validate a token.
  • Loading branch information
dockimbel committed Jun 8, 2020
1 parent 3d23acd commit 0525eb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runtime/lexer.reds
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,8 @@ lexer: context [
do-load: as loader! loaders/index
if :do-load <> null [
catch LEX_ERR [do-load lex s p flags yes]
if events? [
if all [events? system/thrown <> LEX_ERR][
assert all [lex/tail > lex/head lex/tail > lex/buffer]
slot: lex/tail - 1
unless fire-event lex EVT_LOAD TYPE_OF(slot) slot s lex/in-pos [lex/tail: slot]
]
Expand Down
9 changes: 9 additions & 0 deletions tests/source/units/lexer-test.red
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,15 @@ Red [
load integer! datatype! 1 3
]

--test-- "tt-17"
clear logs
--assert [] = transcode/trace {#"^^(00) a"} :lex-logger
--assert logs = [
prescan char! datatype! 1 1x10
error error! datatype! 1 8x10
scan char! datatype! 1 1x11
error error! datatype! 1 8x10
]

===end-group===

Expand Down

0 comments on commit 0525eb1

Please sign in to comment.