From d0b989be26ee70b1cf2ba1dfe2ade225d26a83a4 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 22 Sep 2022 17:51:41 +0200 Subject: [PATCH] SQVM: fix undefined behavior when getting the error line Leave 1 byte for the null terminator. --- r5dev/squirrel/sqvm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r5dev/squirrel/sqvm.cpp b/r5dev/squirrel/sqvm.cpp index 740db93d..8ff6fc08 100644 --- a/r5dev/squirrel/sqvm.cpp +++ b/r5dev/squirrel/sqvm.cpp @@ -319,7 +319,7 @@ void SQVM_CompileError(HSQUIRRELVM v, const SQChar* pszError, const SQChar* pszF context = SQVM_GetContextIndex(v); #endif - v_SQVM_GetErrorLine(pszFile, nLine, szContextBuf, sizeof(szContextBuf)); + v_SQVM_GetErrorLine(pszFile, nLine, szContextBuf, sizeof(szContextBuf) - 1); Error(static_cast(context), NO_ERROR, "%s SCRIPT COMPILE ERROR: %s\n", SQVM_GetContextName(context), pszError); Error(static_cast(context), NO_ERROR, " -> %s\n\n", szContextBuf);