[Scummvm-git-logs] scummvm master -> 9af2c24f1a964157d8d7437fbe35dfc5389f54b7

Strangerke noreply at scummvm.org
Fri May 24 21:12:36 UTC 2024


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:
9af2c24f1a BAGEL: Fix several PVS Studio issues


Commit: 9af2c24f1a964157d8d7437fbe35dfc5389f54b7
    https://github.com/scummvm/scummvm/commit/9af2c24f1a964157d8d7437fbe35dfc5389f54b7
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-24T22:12:29+01:00

Commit Message:
BAGEL: Fix several PVS Studio issues

Changed paths:
    engines/bagel/boflib/sound.cpp
    engines/bagel/boflib/string.cpp
    engines/bagel/dialogs/save_dialog.cpp
    engines/bagel/spacebar/nav_window.cpp
    engines/bagel/spacebar/sraf_computer.cpp


diff --git a/engines/bagel/boflib/sound.cpp b/engines/bagel/boflib/sound.cpp
index 8555fecbbbb..6506bbe9353 100644
--- a/engines/bagel/boflib/sound.cpp
+++ b/engines/bagel/boflib/sound.cpp
@@ -818,7 +818,7 @@ void CBofSound::audioTask() {
 						pSound->stop();
 					}
 
-				} else if (pSound->_bInQueue && !pSound->_bStarted) {
+				} else if (pSound->_bInQueue) {
 					// If this is a Queued sound, and has not already started
 					// And it is time to play
 					if ((CBofSound *)_cQueue[pSound->_iQSlot]->getQItem() == pSound) {
diff --git a/engines/bagel/boflib/string.cpp b/engines/bagel/boflib/string.cpp
index 0f50d8bb4ec..3b0e5fd6a11 100644
--- a/engines/bagel/boflib/string.cpp
+++ b/engines/bagel/boflib/string.cpp
@@ -137,18 +137,14 @@ void CBofString::copy(const char *pszBuf) {
 
 	_nLength = 0;
 	if (pszBuf != nullptr) {
-		int n;
-		n = strlen(pszBuf);
+		int n = strlen(pszBuf);
 
 		if (NORMALIZEBUFFERSIZE() <= n) {
 			allocBuffer(n + 1);
 		}
 
 		Common::strcpy_s(_pszData, n + 1, pszBuf);
-
-		if (_pszData != nullptr) {
-			_nLength = (uint16)strlen(_pszData);
-		}
+		_nLength = (uint16)strlen(_pszData);
 	}
 }
 
@@ -260,14 +256,11 @@ void CBofString::concatInPlace(int nSrcLen, const char *lpszSrcData) {
 			else
 				lpszOldData = new char[_nLength + nSrcLen + 1];
 
-			if (lpszOldData != nullptr) {
-				memcpy(lpszOldData, _pszData, (_nLength + 1) * sizeof(char));
+			memcpy(lpszOldData, _pszData, (_nLength + 1) * sizeof(char));
+			concatCopy(_nLength, lpszOldData, nSrcLen, lpszSrcData, _nLength + nAllocAmount);
 
-				concatCopy(_nLength, lpszOldData, nSrcLen, lpszSrcData, _nLength + nAllocAmount);
-
-				if (lpszOldData != szLocalBuff)
-					delete[] lpszOldData;
-			}
+			if (lpszOldData != szLocalBuff)
+				delete[] lpszOldData;
 		}
 	} else {
 
diff --git a/engines/bagel/dialogs/save_dialog.cpp b/engines/bagel/dialogs/save_dialog.cpp
index a8af3400760..8667f41d632 100644
--- a/engines/bagel/dialogs/save_dialog.cpp
+++ b/engines/bagel/dialogs/save_dialog.cpp
@@ -197,10 +197,7 @@ ErrorCode CBagSaveDialog::attach() {
 	_pListBox->updateWindow();
 
 	if (_nSelectedItem != -1) {
-		if (_pEditText != nullptr) {
-			_pEditText->setFocus();
-		}
-
+		_pEditText->setFocus();
 		_pListBox->setSelectedItem(_nSelectedItem, false);
 
 		if (_nSelectedItem >= 9) {
diff --git a/engines/bagel/spacebar/nav_window.cpp b/engines/bagel/spacebar/nav_window.cpp
index 28ee4cc329d..aacc1d6e7d7 100644
--- a/engines/bagel/spacebar/nav_window.cpp
+++ b/engines/bagel/spacebar/nav_window.cpp
@@ -1332,7 +1332,6 @@ void CNavWindow::calcFuel(double hf) {
 			pause();
 			CBofString sNebDir(NEBSIM3_BMP);
 			fixPathName(sNebDir);
-			assert(_pBackdrop != nullptr);
 			_bmptwo = new CBofBitmap(sNebDir.getBuffer(), _pPal);
 			setBackground(_bmptwo);
 			_cargo = 100 + 75 + 28 + 45 + 14;
diff --git a/engines/bagel/spacebar/sraf_computer.cpp b/engines/bagel/spacebar/sraf_computer.cpp
index f94d2783993..8610b2dfe27 100644
--- a/engines/bagel/spacebar/sraf_computer.cpp
+++ b/engines/bagel/spacebar/sraf_computer.cpp
@@ -825,20 +825,17 @@ SrafComputer::~SrafComputer() {
 	// These lists are persistent across turning the computer on and off, so
 	// delete them only at the end of the game, not when you turn on/off the
 	// computer (attach/detach)
-	if (_pSellerSummaryList != nullptr) {
-		delete _pSellerSummaryList;
-		_pSellerSummaryList = nullptr;
-	}
+	delete _pSellerSummaryList;
+	_pSellerSummaryList = nullptr;
 
-	if (_pBuyerSummaryList != nullptr) {
-		delete _pBuyerSummaryList;
-		_pBuyerSummaryList = nullptr;
-	}
+	delete _pBuyerSummaryList;
+	_pBuyerSummaryList = nullptr;
 
-	if (_pTeamList != nullptr) {
-		delete _pTeamList;
-		_pTeamList = nullptr;
-	}
+	delete _pTeamList;
+	_pTeamList = nullptr;
+
+	delete _pLBox;
+	_pLBox = nullptr;
 
 	// We grab these bad babies in the attach sequence, but since
 	// we need them to live past having the computer on, we need to
@@ -2672,7 +2669,7 @@ void SrafComputer::onListBuyerBids() {
 		szLocalBuff[0] = '\0';
 		CBofString sStr2(szLocalBuff, 256);
 
-		if (index >= 0 && index < NUM_BUYERS) {
+		if (index >= 0) {
 			sStr2 = buildSrafDir(g_stBuyerBids[index]._pszBuyerBio);
 			displayTextScreen(sStr2);
 		}
@@ -2790,12 +2787,12 @@ void SrafComputer::onListDispatchTeam() {
 				} else if (cMeetMember.ptInRect(cPoint)) {         // if so, put a checkmark in that column.
 					// Uncheck any member we already have checked, this is a singular operation
 					nMeetMember = getMeetMember(nListToCheck);
-					if (nMeetMember != -1) {
+					if (nMeetMember != -1 && nMeetMember < NUM_OTHER_PARTYS) {
 						g_stOtherPartys[nMeetMember]._bMeetWith = false;
 					}
 
 					// Now put the check mark in the column for the new guy to meet
-					if (nMeetMember != nElementIndex) {
+					if (nMeetMember != nElementIndex && nMeetMember < NUM_OTHER_PARTYS) {
 						g_stOtherPartys[nElementIndex]._bMeetWith = true;
 						bInMeetMemberColumn = true;
 					}
@@ -2842,12 +2839,12 @@ void SrafComputer::onListDispatchTeam() {
 
 					// Uncheck any member we already have checked, this is a singular operation
 					nMeetMember = getMeetMember(nListToCheck);
-					if (nMeetMember != -1) {
+					if (nMeetMember != -1 && nMeetMember < NUM_SELLERS) {
 						g_stSellerNames[nMeetMember]._bMeetWith = false;
 					}
 
 					// Now put the check mark in the column for the new guy to meet
-					if (nMeetMember != nElementIndex) {
+					if (nMeetMember != nElementIndex && nMeetMember < NUM_SELLERS) {
 						g_stSellerNames[nElementIndex]._bMeetWith = true;
 						bInMeetMemberColumn = true;
 					}
@@ -3516,11 +3513,9 @@ bool SrafComputer::reportMeetingStatus(int nTeamNumber) {
 			_pTeamList->remove(nTeamNumber);
 			bNeedRedraw = true;
 		}
-	}
 
-	// Failure file, a text file for now.
-	// We'll want to play a sound file, for now, just put the text to the screen
-	if (pszFailureFile || pszSuccessFile) {
+		// Failure file, a text file for now.
+		// We'll want to play a sound file, for now, just put the text to the screen
 		notifyBoss(sResponse, nTeamCaptain);
 	}
 




More information about the Scummvm-git-logs mailing list