1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-20 10:52:41 +01:00

Fix: [Script] Potential out of bounds indexed string access.

This commit is contained in:
Peter Nelson
2026-01-13 18:45:42 +00:00
committed by Peter Nelson
parent 7933b0417d
commit 6fd761d7f6

View File

@@ -1285,8 +1285,8 @@ bool SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPt
if(sq_isnumeric(key)){
SQInteger n=tointeger(key);
std::string_view str = _stringval(self);
if(std::abs(n) < static_cast<SQInteger>(str.size())){
if(n<0)n=str.size()+n;
if (n < 0) n = str.size() + n;
if (n >= 0 && n < static_cast<SQInteger>(str.size())) {
dest=SQInteger(str[n]);
return true;
}