TWP: Fix argument cannot be negative in squirrel.

Coverity CID 1540600
This commit is contained in:
scemino committed 2024-04-06 14:42:26 +02:00
1 parent ef07070954
commit ed5da2b101
1 file changed
+4
+4
View File
@@ -334,7 +334,11 @@ static SQInteger _string_startswith(HSQUIRRELVM v)
sq_getstring(v,2,&str);
sq_getstring(v,3,&cmp);
SQInteger len = sq_getsize(v,2);
if(len < 0)
len = 0;
SQInteger cmplen = sq_getsize(v,3);
if(cmplen < 0)
len = 0;
SQBool ret = SQFalse;
if((len >=0) && (cmplen >=0) && (cmplen <= len)) {
ret = memcmp(str,cmp,sq_rsl(cmplen)) == 0 ? SQTrue : SQFalse;