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

AndywinXp noreply at scummvm.org
Mon Oct 16 06:34:57 UTC 2023


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

Summary:
c1cd0dec79 SWORD1: Fix uninit variable issues


Commit: c1cd0dec796e89b24155fbea735a014a47ec59d4
    https://github.com/scummvm/scummvm/commit/c1cd0dec796e89b24155fbea735a014a47ec59d4
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-10-16T08:34:49+02:00

Commit Message:
SWORD1: Fix uninit variable issues

Coverity issues:
CID 1522857
CID 1522855
CID 1522854
CID 1522853
CID 1522852

Changed paths:
    engines/sword1/control.h
    engines/sword1/logic.h
    engines/sword1/screen.cpp
    engines/sword1/sound.cpp


diff --git a/engines/sword1/control.h b/engines/sword1/control.h
index d0971d9ec3a..8784b9c47b6 100644
--- a/engines/sword1/control.h
+++ b/engines/sword1/control.h
@@ -239,7 +239,7 @@ private:
 	int32 _scroll = 0;
 	int32 _scrollCount = 0;
 
-	uint8 *_restoreBuf;
+	uint8 *_restoreBuf = nullptr;
 	uint32 _selectedSavegame = 0;
 	uint8 _numButtons = 0;
 	uint8 _selectedButton = 0;
diff --git a/engines/sword1/logic.h b/engines/sword1/logic.h
index af4bbd99169..96089534263 100644
--- a/engines/sword1/logic.h
+++ b/engines/sword1/logic.h
@@ -82,7 +82,7 @@ private:
 	EventManager *_eventMan;
 	Menu *_menu;
 	uint32 _newScript; // <= ugly, but I can't avoid it.
-	uint8 _speechClickDelay;
+	uint8 _speechClickDelay = 0;
 	Common::RandomSource _rnd;
 	bool _psxFudgeRandom = false; // Used within fnIdle() and fnRandom() for the PSX version
 
diff --git a/engines/sword1/screen.cpp b/engines/sword1/screen.cpp
index 743ab2156a4..ea6a203436c 100644
--- a/engines/sword1/screen.cpp
+++ b/engines/sword1/screen.cpp
@@ -79,6 +79,13 @@ Screen::Screen(OSystem *system, SwordEngine *vm, ResMan *pResMan, ObjectMan *pOb
 	_scrnSizeY = 0;
 	_gridSizeX = 0;
 	_gridSizeY = 0;
+
+	_paletteFadeInfo.fadeCount = 0;
+	_paletteFadeInfo.paletteCount = 0;
+	_paletteFadeInfo.paletteIndex = 0;
+	_paletteFadeInfo.paletteStatus = NO_FADE;
+	memset(_paletteFadeInfo.srcPalette, 0, sizeof(_paletteFadeInfo.srcPalette));
+	memset(_paletteFadeInfo.dstPalette, 0, sizeof(_paletteFadeInfo.dstPalette));
 }
 
 Screen::~Screen() {
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index 69748dd890f..fefe630fead 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -49,7 +49,8 @@ Sound::Sound(Audio::Mixer *mixer, SwordEngine *vm, ResMan *pResMan)
 	_mixer = mixer;
 	_resMan = pResMan;
 	_bigEndianSpeech = false;
-	_cowHeader = NULL;
+	_cowHeader = nullptr;
+	_cowMode = CowWave;
 	_endOfQueue = 0;
 	_currentCowFile = 0;
 
@@ -116,7 +117,7 @@ void Sound::checkSpeechFileEndianness() {
 	}
 
 	// Testing for endianness makes sense only if using the uncompressed files.
-	if (_cowHeader == NULL || (_cowMode != CowWave && _cowMode != CowDemo))
+	if (_cowHeader == nullptr || (_cowMode != CowWave && _cowMode != CowDemo))
 		return;
 
 	// I picked the sample to use randomly (I just made sure it is long enough so that there is
@@ -128,7 +129,7 @@ void Sound::checkSpeechFileEndianness() {
 	uint32 sampleSize = _cowHeader[locIndex + (localNo * 2)];
 	uint32 index = _cowHeader[locIndex + (localNo * 2) - 1];
 	if (sampleSize) {
-		uint32 size;
+		uint32 size = 0;
 		bool leOk = false, beOk = false;
 		// Compute average of difference between two consecutive samples for both BE and LE
 
@@ -343,7 +344,7 @@ void Sound::newScreen(uint32 screen) {
 }
 
 void Sound::startSpeech(uint16 roomNo, uint16 localNo) {
-	if (_cowHeader == NULL) {
+	if (_cowHeader == nullptr) {
 		warning("Sound::startSpeech: COW file isn't open");
 		return;
 	}
@@ -674,7 +675,7 @@ void Sound::initCowSystem() {
 void Sound::closeCowSystem() {
 	_cowFile.close();
 	free(_cowHeader);
-	_cowHeader = NULL;
+	_cowHeader = nullptr;
 	_currentCowFile = 0;
 }
 




More information about the Scummvm-git-logs mailing list