From d26a57fe93d8e4b2beddc2b314139445206a9439 Mon Sep 17 00:00:00 2001 From: Vindaar Date: Thu, 11 Oct 2018 14:21:38 +0200 Subject: [PATCH] append null terminator to source when creating `StringSource` This makes editing the lexer unnecessary. --- yaml/private/lex.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yaml/private/lex.nim b/yaml/private/lex.nim index 3da66c5..15fe989 100644 --- a/yaml/private/lex.nim +++ b/yaml/private/lex.nim @@ -1181,6 +1181,9 @@ proc newYamlLexer*(source: string, startAt: int = 0): YamlLexer GC_unref(cast[ref StringSource](x.source)) ) var sChar = '\0' + # append a `\0` at the very end to work around null terminator being + # inaccessible + sSource.src.add sChar if source.len > 0: sChar = sSource.src[startAt] result[] = YamlLexerObj(buf: "", source: cast[pointer](sSource),