mirror of https://github.com/status-im/NimYAML.git
append null terminator to source when creating `StringSource`
This makes editing the lexer unnecessary.
This commit is contained in:
parent
ba06599b7d
commit
d26a57fe93
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue