From acdab59d94bf73309166e7470cab715d0d409343 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 15 Oct 2023 16:06:49 +0800 Subject: [PATCH] Update cJSONw.cpp --- 3rd/cjson/src/cJSONw.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/3rd/cjson/src/cJSONw.cpp b/3rd/cjson/src/cJSONw.cpp index f7876be6..9877962f 100644 --- a/3rd/cjson/src/cJSONw.cpp +++ b/3rd/cjson/src/cJSONw.cpp @@ -115,8 +115,12 @@ void add_module_cjson(VM* vm){ const Str& string = CAST(Str&, args[0]); cJSON *json = cJSON_ParseWithLength(string.data, string.size); if(json == NULL){ - const char* err = cJSON_GetErrorPtr(); - vm->IOError(fmt("cjson: ", err)); + const char* start = cJSON_GetErrorPtr(); + const char* end = start; + while(*end != '\0' && *end != '\n'){ + end++; + } + vm->IOError(fmt("cjson: ", std::string_view(start, end-start))); UNREACHABLE(); } PyObject* output = convert_cjson_to_python_object(json, vm);