aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2017-11-19 12:46:21 -0600
committerColin Snover2017-11-19 12:48:14 -0600
commit617497d09454694c8601c044613e56c75b777062 (patch)
tree2b29ca1c8b19ad0ea70c371cfae33a17e89cc85a
parentd874208520746df2d73b775902e3269350e9ea40 (diff)
downloadscummvm-rg350-617497d09454694c8601c044613e56c75b777062.tar.gz
scummvm-rg350-617497d09454694c8601c044613e56c75b777062.tar.bz2
scummvm-rg350-617497d09454694c8601c044613e56c75b777062.zip
SCI: Fix UB shifting negative integers
-rw-r--r--engines/sci/decompressor.cpp2
-rw-r--r--engines/sci/graphics/cursor.cpp2
-rw-r--r--engines/sci/resource.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/engines/sci/decompressor.cpp b/engines/sci/decompressor.cpp
index ca2298e67e..158119fe86 100644
--- a/engines/sci/decompressor.cpp
+++ b/engines/sci/decompressor.cpp
@@ -89,7 +89,7 @@ uint32 Decompressor::getBitsLSB(int n) {
// fetching more data to buffer if needed
if (_nBits < n)
fetchBitsLSB();
- uint32 ret = (_dwBits & ~((~0) << n));
+ uint32 ret = (_dwBits & ~(0xFFFFFFFFU << n));
_dwBits >>= n;
_nBits -= n;
return ret;
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index 6b18dce518..9c26d816a1 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -113,7 +113,7 @@ void GfxCursor::kernelSetShape(GuiResourceId resourceId) {
byte colorMapping[4];
int16 x, y;
byte color;
- int16 maskA, maskB;
+ uint16 maskA, maskB;
byte *pOut;
int16 heightWidth;
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index af2ff60d59..eb786bce03 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1805,7 +1805,7 @@ int ResourceManager::readResourceMapSCI0(ResourceSource *map) {
}
}
- addResource(resId, source, offset & (((~bMask) << 24) | 0xFFFFFF), 0, map->getLocationName());
+ addResource(resId, source, offset & ((((byte)~bMask) << 24) | 0xFFFFFF), 0, map->getLocationName());
}
} while (!fileStream->eos());