SCI: Fix UB shifting negative integers

This commit is contained in:
Colin Snover 2017-11-19 12:46:21 -06:00
parent d874208520
commit 617497d094
3 changed files with 3 additions and 3 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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());