From 681b1928b4fc54f0701fe21f091227ff180185a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Sat, 23 Nov 2024 13:46:33 +0100 Subject: [PATCH] Fix #13110: [Script] convert table keys to string when generating JSON (#13113) --- src/script/api/script_admin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/script/api/script_admin.cpp b/src/script/api/script_admin.cpp index 4288233d97..858b855231 100644 --- a/src/script/api/script_admin.cpp +++ b/src/script/api/script_admin.cpp @@ -77,11 +77,11 @@ bool ScriptAdminMakeJSON(nlohmann::json &json, HSQUIRRELVM vm, SQInteger index, sq_pushnull(vm); while (SQ_SUCCEEDED(sq_next(vm, index - 1))) { - /* Squirrel ensure the key is a string. */ - assert(sq_gettype(vm, -2) == OT_STRING); + sq_tostring(vm, -2); const SQChar *buf; - sq_getstring(vm, -2, &buf); + sq_getstring(vm, -1, &buf); std::string key = std::string(buf); + sq_pop(vm, 1); nlohmann::json value; bool res = ScriptAdminMakeJSON(value, vm, -1, depth + 1);