Browse Source

Merge pull request #222 from GMScribe/master

Fixed global swap2() providing incorrect results
Alberto Demichelis 5 years ago
parent
commit
9111578297
1 changed files with 2 additions and 2 deletions
  1. 2 2
      sqstdlib/sqstdblob.cpp

+ 2 - 2
sqstdlib/sqstdblob.cpp

@@ -205,8 +205,8 @@ static SQInteger _g_blob_swap2(HSQUIRRELVM v)
 {
     SQInteger i;
     sq_getinteger(v,2,&i);
-    short s=(short)i;
-    sq_pushinteger(v,(s<<8)|((s>>8)&0x00FF));
+    unsigned short s = (unsigned short)i;
+    sq_pushinteger(v, ((s << 8) | ((s >> 8) & 0x00FFu)) & 0xFFFFu);
     return 1;
 }