From 1c9f9c8f9f6d1da380384e91f5b8559bba4ce02e Mon Sep 17 00:00:00 2001 From: q66 Date: Thu, 22 Sep 2016 01:15:51 +0200 Subject: [PATCH] safe lexing with unterminated strings --- src/cs_vm.hh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cs_vm.hh b/src/cs_vm.hh index 8b3cafa..8930457 100644 --- a/src/cs_vm.hh +++ b/src/cs_vm.hh @@ -218,7 +218,10 @@ struct GenState { return *source++; } - char current(int ahead = 0) { + char current(ostd::Size ahead = 0) { + if (source.size() <= ahead) { + return '\0'; + } return source[ahead]; }