[Scummvm-git-logs] scummvm master -> cc495876792815dc3885516cac3957a4d805033d

athrxx noreply at scummvm.org
Mon Jan 29 23:36:07 UTC 2024


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bf04727a30 KYRA: coverity fixes
0baa6b593a SCUMM: coverity fixes
cc49587679 SCUMM: more coverity fixes


Commit: bf04727a3045edc3bed5e2d39ba072c06d18a915
    https://github.com/scummvm/scummvm/commit/bf04727a3045edc3bed5e2d39ba072c06d18a915
Author: athrxx (athrxx at scummvm.org)
Date: 2024-01-30T00:35:39+01:00

Commit Message:
KYRA: coverity fixes

Changed paths:
    engines/kyra/gui/gui_lol.cpp
    engines/kyra/gui/gui_v2.cpp
    engines/kyra/gui/saveload_eob.cpp
    engines/kyra/resource/resource.cpp
    engines/kyra/sound/sound_amiga_eob.cpp


diff --git a/engines/kyra/gui/gui_lol.cpp b/engines/kyra/gui/gui_lol.cpp
index 4c6f549f35d..144bc9fd3fe 100644
--- a/engines/kyra/gui/gui_lol.cpp
+++ b/engines/kyra/gui/gui_lol.cpp
@@ -812,7 +812,7 @@ void LoLEngine::gui_triggerEvent(int eventType) {
 	}
 
 	removeInputTop();
-	_eventList.push_back(Event(evt, true));
+	_eventList.push_back(Event(Common::move(evt), true));
 	_preserveEvents = true;
 }
 
diff --git a/engines/kyra/gui/gui_v2.cpp b/engines/kyra/gui/gui_v2.cpp
index ce180447d24..4091139df50 100644
--- a/engines/kyra/gui/gui_v2.cpp
+++ b/engines/kyra/gui/gui_v2.cpp
@@ -482,7 +482,7 @@ void GUI_v2::setupSavegameNames(Menu &menu, int num) {
 			menu.item[i].saveSlot = _saveSlots[i + _savegameOffset];
 			menu.item[i].enabled = true;
 			menu.item[i].useItemString = true;
-			menu.item[i].itemString = s;
+			menu.item[i].itemString = Common::move(s);
 			delete in;
 		}
 	}
diff --git a/engines/kyra/gui/saveload_eob.cpp b/engines/kyra/gui/saveload_eob.cpp
index f8a6a4bff3a..2b8c4201c95 100644
--- a/engines/kyra/gui/saveload_eob.cpp
+++ b/engines/kyra/gui/saveload_eob.cpp
@@ -961,7 +961,7 @@ Common::String EoBCoreEngine::readOriginalSaveFile(const Common::Path &file) {
 		t->extraProperties = in.readUint16();
 	}
 
-	return in.err() ? Common::String() : desc;
+	return in.err() ? Common::String() : Common::move(desc);
 }
 
 static uint32 encodeFrame4(const uint8 *src, uint8 *dst, uint32 insize) {
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index 78bb1d4c7d9..746909f3498 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -55,7 +55,7 @@ Common::Archive *Resource::loadKyra1MacInstaller() {
 				error("Legend of Kyrandia installer file part %s is too short", partName.toString().c_str());
 			parts.push_back(Common::SharedPtr<Common::SeekableReadStream>(new Common::SeekableSubReadStream(stream, 100, stream->size(), DisposeAfterUse::YES)));
 		}
-		return loadStuffItArchive(new Common::ConcatReadStream(parts), "Install Legend of Kyrandia", "Legend of Kyrandia(TM) Installer.*");
+		return loadStuffItArchive(new Common::ConcatReadStream(Common::move(parts)), "Install Legend of Kyrandia", "Legend of Kyrandia(TM) Installer.*");
 	}
 
 	return nullptr;
diff --git a/engines/kyra/sound/sound_amiga_eob.cpp b/engines/kyra/sound/sound_amiga_eob.cpp
index ed84aeb35ce..b2625593388 100644
--- a/engines/kyra/sound/sound_amiga_eob.cpp
+++ b/engines/kyra/sound/sound_amiga_eob.cpp
@@ -157,7 +157,7 @@ void SoundAmiga_EoB::playTrack(uint8 track) {
 
 	if (!newSound.empty() && _ready) {
 		_driver->startSound(newSound);
-		_lastSound = newSound;
+		_lastSound = Common::move(newSound);
 	}
 }
 
@@ -207,7 +207,7 @@ void SoundAmiga_EoB::playSoundEffect(uint16 track, uint8 volume) {
 				debugC(5, kDebugLevelSound, "SoundAmiga_EoB::playSoundEffect(): Triggered workaround for wrongly named resource: '%s'", newSound.c_str());
 		}
 
-		_lastSound = newSound;
+		_lastSound = Common::move(newSound);
 	}
 }
 


Commit: 0baa6b593ad2e66ceaa70458f47537e9954ab51d
    https://github.com/scummvm/scummvm/commit/0baa6b593ad2e66ceaa70458f47537e9954ab51d
Author: athrxx (athrxx at scummvm.org)
Date: 2024-01-30T00:35:45+01:00

Commit Message:
SCUMM: coverity fixes

Changed paths:
    engines/scumm/charset.h
    engines/scumm/costume.h
    engines/scumm/debugger.cpp
    engines/scumm/he/net/net_lobby.cpp
    engines/scumm/he/net/net_lobby.h
    engines/scumm/imuse/imuse_internal.h
    engines/scumm/imuse/imuse_part.cpp
    engines/scumm/players/player_mac_indy3.cpp
    engines/scumm/players/player_sid.cpp
    engines/scumm/players/player_towns.cpp
    engines/scumm/players/player_v2base.cpp
    engines/scumm/script_v5.cpp


diff --git a/engines/scumm/charset.h b/engines/scumm/charset.h
index 165e6f55239..9cb11a3df14 100644
--- a/engines/scumm/charset.h
+++ b/engines/scumm/charset.h
@@ -168,7 +168,8 @@ protected:
 	VirtScreenNumber _drawScreen;
 
 public:
-	CharsetRendererClassic(ScummEngine *vm, int cjkSpacing) : CharsetRendererPC(vm), _cjkSpacing(cjkSpacing) {}
+	CharsetRendererClassic(ScummEngine *vm, int cjkSpacing) : CharsetRendererPC(vm), _width(0), _height(0), _origWidth(0), _origHeight(0),
+		_cjkSpacing(cjkSpacing), _offsX(0), _offsY(0), _charPtr(nullptr), _drawScreen(kMainVirtScreen) {}
 	CharsetRendererClassic(ScummEngine *vm) : CharsetRendererClassic(vm, vm->_game.id == GID_INDY4 &&
 									 (vm->_game.platform == Common::kPlatformMacintosh || vm->_game.platform == Common::kPlatformDOS) &&
 									 vm->_language == Common::JA_JPN ? -3 : 0) {}
diff --git a/engines/scumm/costume.h b/engines/scumm/costume.h
index 9615664cdd1..8ab61e0ae6d 100644
--- a/engines/scumm/costume.h
+++ b/engines/scumm/costume.h
@@ -58,7 +58,7 @@ public:
 	const byte *_dataOffsets;
 	byte _numAnim;
 
-	NESCostumeLoader(ScummEngine *vm) : BaseCostumeLoader(vm) {}
+	NESCostumeLoader(ScummEngine *vm) : BaseCostumeLoader(vm), _id(0), _baseptr(nullptr), _dataOffsets(nullptr), _numAnim(0) {}
 	void loadCostume(int id) override;
 	void costumeDecodeData(Actor *a, int frame, uint usemask) override;
 	bool increaseAnims(Actor *a) override;
@@ -88,7 +88,9 @@ protected:
 	uint16 _palette[32];
 
 public:
-	ClassicCostumeRenderer(ScummEngine *vm) : BaseCostumeRenderer(vm), _loaded(vm) {}
+	ClassicCostumeRenderer(ScummEngine *vm) : BaseCostumeRenderer(vm), _loaded(vm), _scaleIndexX(0), _scaleIndexY(0) {
+		memset(_palette, 0, sizeof(_palette));
+	}
 
 	void setPalette(uint16 *palette) override;
 	void setFacing(const Actor *a) override;
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp
index db6d6e7c1e2..c9dcb68a396 100644
--- a/engines/scumm/debugger.cpp
+++ b/engines/scumm/debugger.cpp
@@ -1387,7 +1387,7 @@ bool ScummDebugger::Cmd_PrintGrail(int argc, const char **argv) {
 bool ScummDebugger::Cmd_Passcode(int argc, const char **argv) {
 	if (argc > 1) {
 		_vm->_bootParam = atoi(argv[1]);
-		int args[16];
+		int args[NUM_SCRIPT_LOCAL];
 		memset(args, 0, sizeof(args));
 		args[0] = _vm->_bootParam;
 
diff --git a/engines/scumm/he/net/net_lobby.cpp b/engines/scumm/he/net/net_lobby.cpp
index 7ab07911fb2..a31b2f3353b 100644
--- a/engines/scumm/he/net/net_lobby.cpp
+++ b/engines/scumm/he/net/net_lobby.cpp
@@ -74,7 +74,7 @@ void Lobby::doNetworkOnceAFrame() {
 	}
 }
 
-void Lobby::send(Common::JSONObject data) {
+void Lobby::send(Common::JSONObject &data) {
 	if (!_socket) {
 		warning("LOBBY: Attempted to send data while not connected to server");
 		return;
diff --git a/engines/scumm/he/net/net_lobby.h b/engines/scumm/he/net/net_lobby.h
index ec18ea1c14c..616cdb3932c 100644
--- a/engines/scumm/he/net/net_lobby.h
+++ b/engines/scumm/he/net/net_lobby.h
@@ -88,7 +88,7 @@ public:
 	~Lobby();
 
 	void doNetworkOnceAFrame();
-	void send(Common::JSONObject data);
+	void send(Common::JSONObject &data);
 
 	int32 dispatch(int op, int numArgs, int32 *args);
 
diff --git a/engines/scumm/imuse/imuse_internal.h b/engines/scumm/imuse/imuse_internal.h
index 967e1c9fe5f..a3ccf89298c 100644
--- a/engines/scumm/imuse/imuse_internal.h
+++ b/engines/scumm/imuse/imuse_internal.h
@@ -129,7 +129,7 @@ struct ParameterFader {
 	uint32 total_time;
 	uint32 current_time;
 
-	ParameterFader() { param = 0; }
+	ParameterFader() : param(0), start(0), end(0), total_time(0), current_time(0) {}
 	void init() { param = 0; }
 };
 
diff --git a/engines/scumm/imuse/imuse_part.cpp b/engines/scumm/imuse/imuse_part.cpp
index 98279820845..7b4c2ca506d 100644
--- a/engines/scumm/imuse/imuse_part.cpp
+++ b/engines/scumm/imuse/imuse_part.cpp
@@ -64,6 +64,7 @@ Part::Part() {
 	_percussion = 0;
 	_bank = 0;
 	_unassigned_instrument = false;
+	_se = nullptr;
 }
 
 void Part::saveLoadWithSerializer(Common::Serializer &ser) {
diff --git a/engines/scumm/players/player_mac_indy3.cpp b/engines/scumm/players/player_mac_indy3.cpp
index 33b55724616..6d593ce106d 100644
--- a/engines/scumm/players/player_mac_indy3.cpp
+++ b/engines/scumm/players/player_mac_indy3.cpp
@@ -1168,7 +1168,7 @@ void I3MPlayer::updateSong() {
 		}
 	}
 
-	for (int i = _numMusicChannels - 1; i >= 0; --i)
+	for (int i = 0; i < _numMusicChannels; ++i)
 		_mdrv->setRate(i, _lastSong ? _musicChannels[i]->checkPeriod() : 0);
 	if (_songPlaying)
 		_mdrv->setDuration(10);
diff --git a/engines/scumm/players/player_sid.cpp b/engines/scumm/players/player_sid.cpp
index 6fdb87edd0b..cc6e8b7e4ce 100644
--- a/engines/scumm/players/player_sid.cpp
+++ b/engines/scumm/players/player_sid.cpp
@@ -1007,6 +1007,7 @@ void Player_SID::releaseResourceBySound(int resID) { // $5088
 
 void Player_SID::readVec6Data(int x, int *offset, uint8 *songFilePtr, int chanResID) { // $4E99
 	//vec5[x] = songFilePtr;
+	assert(x < ARRAYSIZE(vec6));
 	vec6[x] = songFilePtr[*offset];
 	*offset += 2;
 	_soundQueue[x] = chanResID;
diff --git a/engines/scumm/players/player_towns.cpp b/engines/scumm/players/player_towns.cpp
index 15c89bb83ee..296e635c85b 100644
--- a/engines/scumm/players/player_towns.cpp
+++ b/engines/scumm/players/player_towns.cpp
@@ -452,7 +452,7 @@ void Player_Towns_v1::startSoundEx(int sound, int velo, int pan, int note) {
 
 		pan = pan ? (((pan << 7) - pan) + 50) / 100 : 64;
 
-		playPcmTrack(sound, ptr + 6, velo ? velo : ptr[14] >> 1, pan, note ? note : ptr[50], pri);
+		playPcmTrack(sound, ptr + 6, velo, pan, note ? note : ptr[50], pri);
 
 	} else if (ptr[13] == 2) {
 		int volLeft = velo;
diff --git a/engines/scumm/players/player_v2base.cpp b/engines/scumm/players/player_v2base.cpp
index 3c6004bcf61..3c13e9e23f4 100644
--- a/engines/scumm/players/player_v2base.cpp
+++ b/engines/scumm/players/player_v2base.cpp
@@ -536,7 +536,7 @@ void Player_V2Base::execute_cmd(ChannelInfo *channel) {
 				}
 
 				debug(8, "channels[%d]: @%04x note: %3d+%d len: %2d hull: %d mod: %d/%d/%d %s",
-						(uint)(dest_channel - channel), script_ptr ? (uint)(script_ptr - _current_data - 2) : 0,
+						(uint)(dest_channel - channel), (uint)(script_ptr - _current_data - 2),
 						note, (signed short) dest_channel->d.transpose, channel->d.time_left,
 						dest_channel->d.hull_curve, dest_channel->d.freqmod_table,
 						dest_channel->d.freqmod_incr,dest_channel->d.freqmod_multiplier,
diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp
index 166844f215e..a2adf87dfac 100644
--- a/engines/scumm/script_v5.cpp
+++ b/engines/scumm/script_v5.cpp
@@ -831,7 +831,7 @@ void ScummEngine_v5::o5_chainScript() {
 	// FIXME: Do we still need this workaround, 19 years later? I can't
 	// reproduce the original crash anymore, maybe we handle uninitialized
 	// local values the same way the original interpreter did, now?
-	if (_game.id == GID_INDY3 && vm.slot[cur].number == 32 && script == 33) {
+	if (_game.id == GID_INDY3 && cur != 0xFF && vm.slot[cur].number == 32 && script == 33) {
 		vars[5] = vm.localvar[cur][5];
 	}
 


Commit: cc495876792815dc3885516cac3957a4d805033d
    https://github.com/scummvm/scummvm/commit/cc495876792815dc3885516cac3957a4d805033d
Author: athrxx (athrxx at scummvm.org)
Date: 2024-01-30T00:35:49+01:00

Commit Message:
SCUMM: more coverity fixes

Changed paths:
    engines/scumm/actor.cpp
    engines/scumm/actor.h
    engines/scumm/dialogs.cpp
    engines/scumm/imuse/imuse_player.cpp
    engines/scumm/smush/codec47.cpp


diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index 865423a66f6..c5ff8d09434 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -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) {
diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h
index aad01e97061..9c7001564c5 100644
--- a/engines/scumm/actor.h
+++ b/engines/scumm/actor.h
@@ -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;
diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp
index 14431407b15..f6c4fd5d812 100644
--- a/engines/scumm/dialogs.cpp
+++ b/engines/scumm/dialogs.cpp
@@ -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];
 }
 
diff --git a/engines/scumm/imuse/imuse_player.cpp b/engines/scumm/imuse/imuse_player.cpp
index a848d875778..2564a027066 100644
--- a/engines/scumm/imuse/imuse_player.cpp
+++ b/engines/scumm/imuse/imuse_player.cpp
@@ -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);
 	}
 
diff --git a/engines/scumm/smush/codec47.cpp b/engines/scumm/smush/codec47.cpp
index be51165436d..afcb65c5446 100644
--- a/engines/scumm/smush/codec47.cpp
+++ b/engines/scumm/smush/codec47.cpp
@@ -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;




More information about the Scummvm-git-logs mailing list