SCUMM: more coverity fixes

This commit is contained in:
athrxx 2024-01-30 00:24:47 +01:00
parent 0baa6b593a
commit cc49587679
5 changed files with 33 additions and 7 deletions

View File

@ -105,8 +105,11 @@ static const byte v0WalkboxSlantedModifier[0x16] = {
};
Actor::Actor(ScummEngine *scumm, int id) :
_vm(scumm), _number(id) {
assert(_vm != nullptr);
_vm(scumm), _number(id), _visible(false), _shadowMode(0), _flip(false), _frame(0), _walkbox(0), _talkPosX(0), _talkPosY(0),
_talkScript(0), _walkScript(0), _ignoreTurns(false), _drawToBackBuf(false), _layer(0), _heOffsX(0), _heOffsY(0), _heSkipLimbs(false),
_heCondMask(0), _hePaletteNum(0), _heXmapNum(0), _elevation(0), _facing(0), _targetFacing(0), _speedx(0), _speedy(0),
_animProgress(0), _animSpeed(0), _costumeNeedsInit(false) {
assert(_vm != nullptr);
}
void ActorHE::initActor(int mode) {

View File

@ -46,6 +46,14 @@ enum MoveFlags {
};
struct CostumeData {
CostumeData() : animCounter(0), soundCounter(0), soundPos(0), stopped(0) {
memset(animType, 0, sizeof(animType));
memset(curpos, 0xFF, sizeof(curpos));
memset(start, 0xFF, sizeof(start));
memset(end, 0xFF, sizeof(end));
memset(frame, 0xFF, sizeof(frame));
}
byte animType[16];
uint16 animCounter;
byte soundCounter;

View File

@ -444,14 +444,17 @@ const char *InfoDialog::getPlainEngineString(int stringno, bool forceHardcodedSt
return nullptr;
if (_vm->_game.version == 8) {
assert(stringno - 1 < ARRAYSIZE(string_map_table_v8));
return string_map_table_v8[stringno - 1].string;
} else if (_vm->_game.version == 7) {
assert(stringno - 1 < ARRAYSIZE(string_map_table_v7));
result = (const char *)_vm->getStringAddressVar(string_map_table_v7[stringno - 1].num);
if (!result) {
result = string_map_table_v7[stringno - 1].string;
}
} else if (_vm->_game.version == 6) {
assert(stringno - 1 < ARRAYSIZE(string_map_table_v6));
result = (const char *)_vm->getStringAddressVar(string_map_table_v6[stringno - 1].num);
if (!result) {
@ -784,11 +787,14 @@ const ResString &InfoDialog::getStaticResString(Common::Language lang, int strin
}
if (useHardcodedV3QuitPrompt) {
assert(langIndex < ARRAYSIZE(hardcodedV3QuitPrompt));
return hardcodedV3QuitPrompt[langIndex];
}
if (useFixedDottMenuStrings) {
stringno -= 21;
assert(langIndex < ARRAYSIZE(fixedDottMenuStrings));
assert(stringno < ARRAYSIZE(fixedDottMenuStrings[0]));
return fixedDottMenuStrings[langIndex][stringno];
}
@ -812,6 +818,9 @@ const ResString &InfoDialog::getStaticResString(Common::Language lang, int strin
return altStr;
}
}
assert(langIndex < ARRAYSIZE(strMap1));
assert(stringno < ARRAYSIZE(strMap1[0]));
return strMap1[langIndex][stringno];
}

View File

@ -416,18 +416,24 @@ void Player::sysEx(const byte *p, uint16 len) {
--len;
// Too big?
if (len >= sizeof(buf) * 2)
if (len >= sizeof(buf))
return;
if (!_scanning) {
for (a = 0; a < len + 1 && a < 19; ++a) {
snprintf((char *)&buf[a * 3], 3 * sizeof(char) + 1, " %02X", (int)p[a]);
}
if (a < len + 1) {
buf[a * 3] = buf[a * 3 + 1] = buf[a * 3 + 2] = '.';
if (a < len + 1 && (a * 3 < sizeof(buf) - 2)) {
if (a * 3 + 2 < sizeof(buf))
buf[a * 3] = buf[a * 3 + 1] = buf[a * 3 + 2] = '.';
else
warning("Player::sysEx(): Message too long (truncated)");
++a;
}
buf[a * 3] = '\0';
if (a * 3 < sizeof(buf))
buf[a * 3] = '\0';
else
warning("Player::sysEx(): Message too long (truncated)");
debugC(DEBUG_IMUSE, "[%02d] SysEx:%s", _id, buf);
}

View File

@ -535,7 +535,7 @@ void SmushDeltaGlyphsDecoder::decode2(byte *dst, const byte *src, int width, int
}
#endif
SmushDeltaGlyphsDecoder::SmushDeltaGlyphsDecoder(int width, int height) {
SmushDeltaGlyphsDecoder::SmushDeltaGlyphsDecoder(int width, int height) : _prevSeqNb(0), _dSrc(nullptr), _paramPtr(nullptr), _dPitch(0), _offset1(0), _offset2(0) {
_lastTableWidth = -1;
_width = width;
_height = height;