From 06b394a483ff65b1454e6bec77dafefc6ef929d6 Mon Sep 17 00:00:00 2001 From: Alistair Lowe Date: Thu, 16 Jul 2020 21:31:57 +0100 Subject: [PATCH] Fixed global swap2() providing incorrect results --- sqstdlib/sqstdblob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqstdlib/sqstdblob.cpp b/sqstdlib/sqstdblob.cpp index 261b938..776a968 100644 --- a/sqstdlib/sqstdblob.cpp +++ b/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; }