From ae72e1595165c0155efd02ccd95bf4cfd40c8658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Tue, 25 Feb 2025 13:13:31 +0100 Subject: [PATCH] Codefix b2c5712: [Script] Squirrel::GetRealInstance doesn't work with negative index (#13658) --- src/script/squirrel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index f5550acb82..3e4abc5e79 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -511,6 +511,7 @@ bool Squirrel::CreateClassInstance(const std::string &class_name, void *real_ins /* static */ SQUserPointer Squirrel::GetRealInstance(HSQUIRRELVM vm, int index, const char *tag) { + if (index < 0) index += sq_gettop(vm) + 1; Squirrel *engine = static_cast(sq_getforeignptr(vm)); std::string class_name = fmt::format("{}{}", engine->GetAPIName(), tag); sq_pushroottable(vm);