Browse Source

Fixed global swap2() providing incorrect results

Alistair Lowe 5 years ago
parent
commit
06b394a483
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;
     SQInteger i;
     sq_getinteger(v,2,&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;
     return 1;
 }
 }