From 5034fef8d048d8d9e5e0228864dacf627d35b96f Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Tue, 7 Jun 2022 12:35:20 +0300 Subject: [PATCH] Avoid a dangerous string to cstring conversion --- json_serialization/reader.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/json_serialization/reader.nim b/json_serialization/reader.nim index aea7f79..b71875b 100644 --- a/json_serialization/reader.nim +++ b/json_serialization/reader.nim @@ -20,7 +20,7 @@ type line*, col*: int UnexpectedField* = object of JsonReaderError - encounteredField*: cstring + encounteredField*: string deserializedType*: cstring ExpectedTokenCategory* = enum @@ -118,7 +118,7 @@ proc raiseIntOverflow*(r: JsonReader, absIntVal: uint64, isNegative: bool) {.nor ex.isNegative = isNegative raise ex -proc raiseUnexpectedField*(r: JsonReader, fieldName, deserializedType: cstring) {.noreturn.} = +proc raiseUnexpectedField*(r: JsonReader, fieldName: string, deserializedType: cstring) {.noreturn.} = var ex = new UnexpectedField ex.assignLineNumber(r) ex.encounteredField = fieldName @@ -593,7 +593,7 @@ proc readValue*[T](r: var JsonReader, value: var T) r.skipSingleJsValue() else: const typeName = typetraits.name(T) - r.raiseUnexpectedField(r.lexer.strVal, typeName) + r.raiseUnexpectedField(r.lexer.strVal, string typeName) if r.lexer.lazyTok == tkComma: r.lexer.next() else: