[Scummvm-git-logs] scummvm master -> 143ba5565999e54e33222ce68de1be2cb046a5ef

dreammaster noreply at scummvm.org
Tue Sep 30 11:11:19 UTC 2025


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

Summary:
143ba55659 BAGEL: MINIGAMES: Fix Beacon Coverity warnings


Commit: 143ba5565999e54e33222ce68de1be2cb046a5ef
    https://github.com/scummvm/scummvm/commit/143ba5565999e54e33222ce68de1be2cb046a5ef
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-09-30T04:10:36-07:00

Commit Message:
BAGEL: MINIGAMES: Fix Beacon Coverity warnings

Changed paths:
    engines/bagel/hodjnpodj/beacon/beacon.cpp


diff --git a/engines/bagel/hodjnpodj/beacon/beacon.cpp b/engines/bagel/hodjnpodj/beacon/beacon.cpp
index a7d7a7db09e..74e55d7d587 100644
--- a/engines/bagel/hodjnpodj/beacon/beacon.cpp
+++ b/engines/bagel/hodjnpodj/beacon/beacon.cpp
@@ -215,11 +215,9 @@ CMainWindow::CMainWindow() {
 
 		MyFocusRect(pArtDC, colorBlock[i].rLocation, false);     // standard highlight on button
 
-		if (pMyBrush != nullptr) {                         // If the brush was constructed, delete it
-			pMyBrush->DeleteObject();
-			delete pMyBrush;
-			pMyBrush = nullptr;
-		}
+		pMyBrush->DeleteObject();
+		delete pMyBrush;
+		pMyBrush = nullptr;
 	}
 
 	statRect.SetRect(SIDE_BORDER + ART_WIDTH, TOP_BORDER,
@@ -398,17 +396,16 @@ void CMainWindow::DrawBeams(CDC *pDC) {
 		(*pBigDC).Pie(&rect, End, Start);
 
 		(*pBigDC).SelectObject(pOldPen);
-		if (pMyPen != nullptr) {                           // If the brush was constructed, delete it
-			pMyPen->DeleteObject();
-			delete pMyPen;
-			pMyPen = nullptr;
-		}
+
+		pMyPen->DeleteObject();
+		delete pMyPen;
+		pMyPen = nullptr;
+
 		(*pBigDC).SelectObject(pOldBrush);
-		if (pMyBrush != nullptr) {                         // If the brush was constructed, delete it
-			pMyBrush->DeleteObject();
-			delete pMyBrush;
-			pMyBrush = nullptr;
-		}
+
+		pMyBrush->DeleteObject();
+		delete pMyBrush;
+		pMyBrush = nullptr;
 
 		x = (float)cos(radians);
 		y = (float)sin(radians);
@@ -1222,9 +1219,13 @@ bool CMainWindow::LoadArtWork(CDC *pDC) {
 	inFile.getline(chNumEntries, sizeof(chNumEntries));     // read number of names in file
 	nNumEntries = atoi(chNumEntries);
 	pick = nLastPick;
+	assert(nNumEntries > 0);
+
 	while (pick == nLastPick) {
 		pick = (brand() % nNumEntries) + 1;
 	}
+
+	Common::strcpy_s(ArtName, "");
 	for (i = 0; i < pick; i++) {
 		if (!inFile.eof())
 			inFile.getline(ArtName, sizeof(ArtName));       // load a name
@@ -1306,21 +1307,17 @@ bool CMainWindow::LoadArtWork(CDC *pDC) {
 
 		MyFocusRect(pArtDC, colorBlock[i].rLocation, false);     // standard highlight on button
 
-		if (pMyBrush != nullptr) {                                 // If the brush was constructed, delete it
-			pMyBrush->DeleteObject();
-			delete pMyBrush;
-			pMyBrush = nullptr;
-		}
+		pMyBrush->DeleteObject();
+		delete pMyBrush;
+		pMyBrush = nullptr;
 	}
 
 	pBeaconBitmap = FetchResourceBitmap(pDC, nullptr, IDB_BEACON_BMP);          // Add the lighthouse
 
 	(*pDC).SelectPalette(pPalOld, false);
 
-	if (pTempPalette != nullptr) {
-		pTempPalette->DeleteObject();
-		delete pTempPalette;
-	}
+	pTempPalette->DeleteObject();
+	delete pTempPalette;
 
 	delete pSourceDoc;
 	pSourceDoc = nullptr;
@@ -1469,23 +1466,17 @@ void MyFocusRect(CDC *pDC, CRect rect, bool nPressed) {
 
 	(*pDC).SelectPalette(pPalOld, false);           // Select back the old palette
 
-	if (pMyBrush != nullptr) {                         // If the brush was constructed, delete it
-		pMyBrush->DeleteObject();
-		delete pMyBrush;
-		pMyBrush = nullptr;
-	}
+	pMyBrush->DeleteObject();
+	delete pMyBrush;
+	pMyBrush = nullptr;
 
-	if (pLitePen != nullptr) {                             // If the pen was constructed, delete it
-		pLitePen->DeleteObject();
-		delete pLitePen;
-		pLitePen = nullptr;
-	}
+	pLitePen->DeleteObject();
+	delete pLitePen;
+	pLitePen = nullptr;
 
-	if (pDarkPen != nullptr) {                             // If the pen was constructed, delete it
-		pDarkPen->DeleteObject();
-		delete pDarkPen;
-		pDarkPen = nullptr;
-	}
+	pDarkPen->DeleteObject();
+	delete pDarkPen;
+	pDarkPen = nullptr;
 
 } // End MyFocusRect()
 




More information about the Scummvm-git-logs mailing list