]> ocean-lang.org Git - ocean/commit
scanner: handle missing newline at EOF
authorNeilBrown <neil@brown.name>
Fri, 17 May 2019 13:31:48 +0000 (23:31 +1000)
committerNeilBrown <neil@brown.name>
Fri, 17 May 2019 13:57:53 +0000 (23:57 +1000)
commit83e9fd29cdd342f5324dae5573211b9d311059cf
tree3f966603d8a025a0cd070bd9995353deb2dd131b
parent4b606ddde48d77e17516373af8dc852df3b26651
scanner: handle missing newline at EOF

If there is no newline at EOF, we can see EOF immediately after
a valid symbol.  This can lead to calling close_token() when
state->node is NULL, which crashes.
The code in close_token() only makes sense if state->node is still the
same as token->node.  If it isn't, the token must be at the very end of
its code-node, so a different calculation is needed.

This avoids the NULL deref.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/scanner.mdc