[Scummvm-git-logs] scummvm master -> 66b2bc58df687089ce7edacd9f8314d7efdd67c3

sev- noreply at scummvm.org
Mon Dec 25 13:49:23 UTC 2023


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

Summary:
d3f4fcf160 M4: Replaces strncpy with Common::strlcpy() for safer operations
d810bffb85 M4: Fix wrong argument order. CID 1532903
dbd3fc1e75 M4: Fix copy-paste. CID 1532899
a9b39212c3 M4: Fix memory leak. CID 1532968
e759e4f130 M4: Fix wrong condition check. CID 1532914
c940f06c17 M4: Fix copy-paste error. Assignment instead of comparison. CID 1532923
e60388bdd0 M4: Fix potential crash. CID 1532956
cf51628e81 M4: Fix potential resource leak. CID 1532960
66b2bc58df M4: Fix warning about wrong allocation type. CID 1533014


Commit: d3f4fcf1607cd1d01af3b3a10ade60e595a4afe9
    https://github.com/scummvm/scummvm/commit/d3f4fcf1607cd1d01af3b3a10ade60e595a4afe9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:15:00+01:00

Commit Message:
M4: Replaces strncpy with Common::strlcpy() for safer operations

Changed paths:
    engines/m4/adv_r/adv_chk.cpp
    engines/m4/burger/gui/game_menu.cpp
    engines/m4/burger/gui/interface.cpp
    engines/m4/core/cstring.cpp
    engines/m4/gui/gui_item.cpp
    engines/m4/riddle/gui/interface.cpp


diff --git a/engines/m4/adv_r/adv_chk.cpp b/engines/m4/adv_r/adv_chk.cpp
index 3d918ccd63b..f9c1548cac7 100644
--- a/engines/m4/adv_r/adv_chk.cpp
+++ b/engines/m4/adv_r/adv_chk.cpp
@@ -177,10 +177,10 @@ static void load_def(SysFile *fpdef) {
 
 	buffPtr = &s[0];
 	fpdef->read(&buffPtr, MAX_FILENAME_SIZE);
-	strncpy(_G(myDef)->art_base, s, MAX_FILENAME_SIZE);
+	Common::strlcpy(_G(myDef)->art_base, s, MAX_FILENAME_SIZE);
 
 	fpdef->read(&buffPtr, MAX_FILENAME_SIZE);
-	strncpy(_G(myDef)->picture_base, s, MAX_FILENAME_SIZE);
+	Common::strlcpy(_G(myDef)->picture_base, s, MAX_FILENAME_SIZE);
 
 	buffPtr = &a;
 	fpdef->read(&buffPtr, sizeof(int32));
diff --git a/engines/m4/burger/gui/game_menu.cpp b/engines/m4/burger/gui/game_menu.cpp
index f3afdaf0994..92088229fe5 100644
--- a/engines/m4/burger/gui/game_menu.cpp
+++ b/engines/m4/burger/gui/game_menu.cpp
@@ -842,7 +842,7 @@ menuItem *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
 	}
 	buttonInfo->buttonType = buttonType;
 
-	// Note: prompt is not duplicated, therefore, make sure the name is stored in non-volatile memory 
+	// Note: prompt is not duplicated, therefore, make sure the name is stored in non-volatile memory
 	buttonInfo->prompt = prompt;
 	buttonInfo->specialTag = tag - 1000;
 
@@ -2000,7 +2000,7 @@ bool menu_LoadSprites(const char *series, int32 numSprites) {
 	}
 	_GM(menuSeriesResource) = mem_strdup(series);
 
-	// Update the palette for the menu        
+	// Update the palette for the menu
 	gr_pal_set_range(_GM(menuPalette), 59, 197);  // Rid
 
 	_GM(spriteCount) = numSprites;
@@ -3229,7 +3229,7 @@ void cb_SaveLoad_Save(void *, void *theMenu) {
 
 	// Save the game
 	// Copy the string so the save games will all be "RIPxxx.SAV"
-	strncpy(_G(game).save_file_name, "BURG", 8);
+	Common::strlcpy(_G(game).save_file_name, "BURG", 8);
 	saveGameFailed = (bool)kernel_save_game(_GM(slotSelected), myText->prompt, 80, _GM(saveLoadThumbNail), _GM(sizeofThumbData));
 
 	// If the save game failed, bring up the err menu
@@ -3303,7 +3303,7 @@ void cb_SaveLoad_Load(void *, void *theMenu) {
 
 	// Load the game
 	// Copy the string so the kernel_load_game will find a saved game of the format: "RIPxxx.SAV"
-//	strncpy(_G(game).save_file_name, "BURG", 8);
+//	Common::strlcpy(_G(game).save_file_name, "BURG", 8);
 
 	// Kill the menu
 	DestroySaveLoadMenu(false);
@@ -3513,10 +3513,10 @@ bool load_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y,
 			}
 		}
 
-		// Else we must determine whether the thumbnail needs to be replaced with the empty thumbnail.  
+		// Else we must determine whether the thumbnail needs to be replaced with the empty thumbnail.
 		else {
 
-			// If the mouse has moved outside of the entire range of all 10 buttons, 
+			// If the mouse has moved outside of the entire range of all 10 buttons,
 			//or it is over a button which is not hilited it is to be removed.
 			if (menu_CursorInsideItem(myItem, x, y)
 				|| (x < SL_SCROLL_FIELD_X)
diff --git a/engines/m4/burger/gui/interface.cpp b/engines/m4/burger/gui/interface.cpp
index 5d026525374..04f4f68a2ef 100644
--- a/engines/m4/burger/gui/interface.cpp
+++ b/engines/m4/burger/gui/interface.cpp
@@ -383,7 +383,7 @@ ControlStatus Interface::trackHotspots(int event, int x, int y) {
 			if (!mouse_set_sprite(hotspot->cursor_number))
 				mouse_set_sprite(kArrowCursor);
 
-			strncpy(_verbText, hotspot->verb, 40);
+			Common::strlcpy(_verbText, hotspot->verb, 40);
 		}
 
 		Common::String tmp = (g_engine->getLanguage() == Common::EN_ANY) ?
@@ -393,7 +393,7 @@ ControlStatus Interface::trackHotspots(int event, int x, int y) {
 
 		tmp = hotspot->vocab;
 		tmp.toUppercase();
-		strncpy(_nounText, tmp.c_str(), 40);
+		Common::strlcpy(_nounText, tmp.c_str(), 40);
 
 		_hotspot = hotspot;
 	}
diff --git a/engines/m4/core/cstring.cpp b/engines/m4/core/cstring.cpp
index f6e289d60e4..96053a5d583 100644
--- a/engines/m4/core/cstring.cpp
+++ b/engines/m4/core/cstring.cpp
@@ -70,11 +70,7 @@ void cstrncpy(char *dest, const char *src, const int16 max_len) {
 	if (!src || !dest)
 		return;
 
-	int16 count = 0;
-	do {
-		*dest++ = *src;
-		++count;
-	} while (*src++ && (count < max_len));
+	Common::strlcpy(dest, src, max_len);
 }
 
 char *cstrupr(char *src) {
@@ -151,7 +147,7 @@ void strdel(char *inp, int indx, int count) {
 	if (indx >= (int)strlen(inp) || !count)
 		return;
 
-	strncpy(&inp[indx], &inp[indx + count], count);
+	Common::strlcpy(&inp[indx], &inp[indx + count], count);
 }
 
 
@@ -164,7 +160,7 @@ void strseg(char *work, char *work2, int indx, int count) {
 	char *s = nullptr;
 
 	s = &work2[indx];
-	strncpy(work, s, count);
+	Common::strlcpy(work, s, count);
 }
 
 
diff --git a/engines/m4/gui/gui_item.cpp b/engines/m4/gui/gui_item.cpp
index e2fd6d86a8c..28281f4f38d 100644
--- a/engines/m4/gui/gui_item.cpp
+++ b/engines/m4/gui/gui_item.cpp
@@ -587,7 +587,7 @@ bool ListItemAdd(Item *myItem, char *prompt, int32 listTag, int32 addMode, ListI
 	if (changedItem) newListItem = changedItem;
 	else {
 		if ((newListItem = (ListItem *)mem_alloc(sizeof(ListItem), STR_LIST)) == nullptr) return false;
-		strncpy(newListItem->prompt, prompt, 79);
+		Common::strlcpy(newListItem->prompt, prompt, 80);
 		newListItem->tag = listTag;
 	}
 	//Add it into the list in the correct place...
@@ -1237,7 +1237,7 @@ static int32 CopyTextBlock(Item *myItem) {
 			endBlock = myItem->aux;
 		}
 		numOfCopiedChars = endBlock - beginBlock;
-		strncpy(_G(items).clipBoard, beginBlock, 99);
+		Common::strlcpy(_G(items).clipBoard, beginBlock, 100);
 		if (endBlock - beginBlock <= 99) {
 			_G(items).clipBoard[endBlock - beginBlock] = '\0';
 		} else numOfCopiedChars = 99;
diff --git a/engines/m4/riddle/gui/interface.cpp b/engines/m4/riddle/gui/interface.cpp
index 455da80d938..0a8612c2016 100644
--- a/engines/m4/riddle/gui/interface.cpp
+++ b/engines/m4/riddle/gui/interface.cpp
@@ -396,7 +396,7 @@ ControlStatus Interface::trackHotspots(int event, int x, int y) {
 			if (!mouse_set_sprite(hotspot->cursor_number))
 				mouse_set_sprite(kArrowCursor);
 
-			strncpy(_verbText, hotspot->verb, 40);
+			Common::strlcpy(_verbText, hotspot->verb, 40);
 		}
 
 		Common::String tmp = (g_engine->getLanguage() == Common::EN_ANY) ?
@@ -406,7 +406,7 @@ ControlStatus Interface::trackHotspots(int event, int x, int y) {
 
 		tmp = hotspot->vocab;
 		tmp.toUppercase();
-		strncpy(_nounText, tmp.c_str(), 40);
+		Common::strlcpy(_nounText, tmp.c_str(), 40);
 
 		_hotspot = hotspot;
 	}


Commit: d810bffb85ef2c5dcb74960b60a053d124fb12b7
    https://github.com/scummvm/scummvm/commit/d810bffb85ef2c5dcb74960b60a053d124fb12b7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:18:29+01:00

Commit Message:
M4: Fix wrong argument order. CID 1532903

Changed paths:
    engines/m4/adv_r/adv_player.cpp


diff --git a/engines/m4/adv_r/adv_player.cpp b/engines/m4/adv_r/adv_player.cpp
index f02ec7f7509..fddaf96d396 100644
--- a/engines/m4/adv_r/adv_player.cpp
+++ b/engines/m4/adv_r/adv_player.cpp
@@ -197,7 +197,7 @@ PlayerInfo *player_update_info() {
 }
 
 void player_set_facing_hotspot(int trigger) {
-	player_set_facing_at(trigger, _G(click_x), _G(click_y));
+	player_set_facing_at(_G(click_x), _G(click_y), trigger);
 }
 
 void player_set_facing_at(int x, int y, int trigger) {


Commit: dbd3fc1e7568b7c0610c72f0bf8beed1165dee75
    https://github.com/scummvm/scummvm/commit/dbd3fc1e7568b7c0610c72f0bf8beed1165dee75
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:19:48+01:00

Commit Message:
M4: Fix copy-paste. CID 1532899

Changed paths:
    engines/m4/adv_r/adv_rails.cpp


diff --git a/engines/m4/adv_r/adv_rails.cpp b/engines/m4/adv_r/adv_rails.cpp
index 8304a414cf9..91aad4520ee 100644
--- a/engines/m4/adv_r/adv_rails.cpp
+++ b/engines/m4/adv_r/adv_rails.cpp
@@ -291,7 +291,7 @@ bool intr_LineCrossesRect(int32 line_x1, int32 line_y1, int32 line_x2, int32 lin
 
 		// Because the midpoint is an integer (round-off err), make sure it isn't the same
 		// as one of the two endpoints.
-		if (((mX == p1X) && (mY == p1Y)) || ((mX == p1X) && (mY == p1Y))) {
+		if (((mX == p1X) && (mY == p1Y)) || ((mX == p2X) && (mY == p2Y))) {
 			return false;
 		}
 


Commit: a9b39212c3716135fd398c00b3221242d28ec498
    https://github.com/scummvm/scummvm/commit/a9b39212c3716135fd398c00b3221242d28ec498
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:23:28+01:00

Commit Message:
M4: Fix memory leak. CID 1532968

Changed paths:
    engines/m4/burger/gui/game_menu.cpp


diff --git a/engines/m4/burger/gui/game_menu.cpp b/engines/m4/burger/gui/game_menu.cpp
index 92088229fe5..ece37d2204c 100644
--- a/engines/m4/burger/gui/game_menu.cpp
+++ b/engines/m4/burger/gui/game_menu.cpp
@@ -2227,6 +2227,8 @@ GrBuff *menu_CopyBackground(guiMenu *myMenu, int32 x, int32 y, int32 w, int32 h)
 	srcBuff = myMenu->menuBuffer->get_buffer();
 	destBuff = copyOfBackground->get_buffer();
 	if ((!srcBuff) || (!destBuff)) {
+		delete copyOfBackground;
+
 		return nullptr;
 	}
 


Commit: e759e4f1301cf779e5cec78dc71af619d77f02dd
    https://github.com/scummvm/scummvm/commit/e759e4f1301cf779e5cec78dc71af619d77f02dd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:26:04+01:00

Commit Message:
M4: Fix wrong condition check. CID 1532914

Changed paths:
    engines/m4/burger/gui/gui_cheapo.cpp


diff --git a/engines/m4/burger/gui/gui_cheapo.cpp b/engines/m4/burger/gui/gui_cheapo.cpp
index a6eee5f13df..0f9df209966 100644
--- a/engines/m4/burger/gui/gui_cheapo.cpp
+++ b/engines/m4/burger/gui/gui_cheapo.cpp
@@ -111,7 +111,7 @@ TextField::~TextField() {
 void TextField::set_string(const char *string) {
 	_must_redraw = true;
 
-	if (string == nullptr && string != nullptr) {
+	if (string != nullptr && *string != '\0') {
 		_string[0] = '\0';
 		return;
 	}


Commit: c940f06c17dec9774ccd1c16a0bf40fe1bbfd0f7
    https://github.com/scummvm/scummvm/commit/c940f06c17dec9774ccd1c16a0bf40fe1bbfd0f7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:28:27+01:00

Commit Message:
M4: Fix copy-paste error. Assignment instead of comparison. CID 1532923

Changed paths:
    engines/m4/burger/rooms/section1/room143.cpp


diff --git a/engines/m4/burger/rooms/section1/room143.cpp b/engines/m4/burger/rooms/section1/room143.cpp
index 90b3bfcd01c..d99ed1aa928 100644
--- a/engines/m4/burger/rooms/section1/room143.cpp
+++ b/engines/m4/burger/rooms/section1/room143.cpp
@@ -798,7 +798,7 @@ void Room143::daemon() {
 			default:
 				_G(flags)[V298] = 0;
 				_burlMode = 20;
-				series_play_with_breaks(PLAY9, "143bu04", 0xa00, kCHANGE_BURL_ANIMATION, 3);				
+				series_play_with_breaks(PLAY9, "143bu04", 0xa00, kCHANGE_BURL_ANIMATION, 3);
 				break;
 			}
 			break;
@@ -1384,7 +1384,7 @@ void Room143::conv35() {
 						(node == 12 && entry == 2) ||
 						(node == 13 && entry == 1) ||
 						(node == 15) ||
-						(node = 16 && entry == 0) ||
+						(node == 16 && entry == 0) ||
 						(node == 16 && entry == 2) ||
 						(node == 17 && entry == 0) ||
 						(node == 18 && entry == 0) ||


Commit: e60388bdd05ca2e1b772dc88cd0dba60f986c972
    https://github.com/scummvm/scummvm/commit/e60388bdd05ca2e1b772dc88cd0dba60f986c972
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:37:39+01:00

Commit Message:
M4: Fix potential crash. CID 1532956

Changed paths:
    engines/m4/graphics/gr_sprite.cpp


diff --git a/engines/m4/graphics/gr_sprite.cpp b/engines/m4/graphics/gr_sprite.cpp
index c836facc9c0..09994ed0787 100644
--- a/engines/m4/graphics/gr_sprite.cpp
+++ b/engines/m4/graphics/gr_sprite.cpp
@@ -38,7 +38,10 @@ static uint8 scale_sprite(Buffer *S, Buffer *D, uint32 ScaleX, uint32 ScaleY) {
 	uint16 ErrX, ErrY, i, j;
 	uint8 *pScaled, *pData = S->data;
 
-	if (!D || !S)
+	if (!D)
+		error_show(FL, 'BUF!', "scale sprite NULL D");
+
+	if (!S)
 		error_show(FL, 'BUF!', "scale sprite h:%d w:%d sx:%uld sy:%uld", D->h, D->w, ScaleX, ScaleY);
 
 	/* calculate new x size */


Commit: cf51628e819dec226f1ffa1630d640c2c8a7db18
    https://github.com/scummvm/scummvm/commit/cf51628e819dec226f1ffa1630d640c2c8a7db18
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:42:08+01:00

Commit Message:
M4: Fix potential resource leak. CID 1532960

Changed paths:
    engines/m4/gui/gui_item.cpp


diff --git a/engines/m4/gui/gui_item.cpp b/engines/m4/gui/gui_item.cpp
index 28281f4f38d..4c120a746e0 100644
--- a/engines/m4/gui/gui_item.cpp
+++ b/engines/m4/gui/gui_item.cpp
@@ -491,7 +491,10 @@ Item *ItemAdd(Item *itemList, int32 x, int32 y, int32 w, int32 h, const char *pr
 
 	CorrectItemWidthHeight(item, fontHeight);
 	if (type == LISTBOX) {
-		if (!sizeofGUIelement_border(LISTBOX, &listboxWidth, &listboxHeight)) return nullptr;
+		if (!sizeofGUIelement_border(LISTBOX, &listboxWidth, &listboxHeight)) {
+			Item_destroy(item);
+			return nullptr;
+		}
 		item->listView = (item->h - listboxHeight - 2) / fontHeight;
 	}
 	return item;


Commit: 66b2bc58df687089ce7edacd9f8314d7efdd67c3
    https://github.com/scummvm/scummvm/commit/66b2bc58df687089ce7edacd9f8314d7efdd67c3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-25T14:47:59+01:00

Commit Message:
M4: Fix warning about wrong allocation type. CID 1533014

Changed paths:
    engines/m4/wscript/ws_load.cpp


diff --git a/engines/m4/wscript/ws_load.cpp b/engines/m4/wscript/ws_load.cpp
index 850ca95abb7..d72dd9a3212 100644
--- a/engines/m4/wscript/ws_load.cpp
+++ b/engines/m4/wscript/ws_load.cpp
@@ -119,7 +119,7 @@ bool InitWSAssets() {
 	if ((_GWS(globalCELSnames) = (char **)mem_alloc(sizeof(char *) * 256, "CELS resource table")) == nullptr) {
 		return false;
 	}
-	if ((_GWS(globalCELSHandles) = (MemHandle *)mem_alloc(sizeof(Handle) * 256, "CELS Handles table")) == nullptr) {
+	if ((_GWS(globalCELSHandles) = (MemHandle *)mem_alloc(sizeof(MemHandle *) * 256, "CELS Handles table")) == nullptr) {
 		return false;
 	}
 	if ((_GWS(globalCELSoffsets) = (int32 *)mem_alloc(sizeof(int32 *) * 256, "CELS offsets table")) == nullptr) {
@@ -280,7 +280,7 @@ bool LoadWSAssets(const char *wsAssetName, RGB8 *myPalette) {
 		finished = true;
 	}
 
-	// Process each chunk according to type 
+	// Process each chunk according to type
 	while (!finished) {
 		// Read in the chunk size and hash number
 		if (!GetNextint32(&parseAssetPtr, endOfAssetBlock, &chunkSize)) {
@@ -870,7 +870,7 @@ static int32 ProcessCELS(const char * /*assetName*/, char **parseAssetPtr, char
 
 		*parseAssetPtr += *numColors << 2;
 
-		// The palette info has been processed, now it can be stored 
+		// The palette info has been processed, now it can be stored
 		if (myPalette) {
 			tempPtr = (uint32 *)(&palData[1]);
 			for (i = 0; i < (uint32)*numColors; i++) {
@@ -1302,7 +1302,7 @@ int32 ws_get_sprite_width(uint32 hash, int32 index) {
 }
 
 int32 ws_get_sprite_height(uint32 hash, int32 index) {
-	uint32 *celsPtr, *offsets, *data, *myCelSource; 
+	uint32 *celsPtr, *offsets, *data, *myCelSource;
 	int32 numCels;
 
 	// Ensure the WS loader has been initialized.




More information about the Scummvm-git-logs mailing list