[Scummvm-git-logs] scummvm master -> 88816ce32f460130aff0f8044732e81bbcd2bf4e

dreammaster noreply at scummvm.org
Mon Jul 6 01:08:03 UTC 2026


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

Summary:
4a4e2e6bed MADS: Change SIZE functions to return type size_t
1f3f425ddc MADS: Delete remove file call
99335c47f9 MADS: Fixing Coverity warnings
d1c0aae1e1 MADS: Fixing dialog Coverity warnings
0e25f15218 MADS: Fixing env Coverity warnings
5c7f609037 MADS: Fixing game Coverity warnings
88816ce32f MADS: Fixing inter/kernel Coverity warnings


Commit: 4a4e2e6bed68822ed7dc3c703058c32e2c34b62e
    https://github.com/scummvm/scummvm/commit/4a4e2e6bed68822ed7dc3c703058c32e2c34b62e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-07-06T11:05:31+10:00

Commit Message:
MADS: Change SIZE functions to return type size_t

Changed paths:
    engines/mads/madsv2/core/anim.h
    engines/mads/madsv2/core/color.h
    engines/mads/madsv2/core/conv.h
    engines/mads/madsv2/core/copy.h
    engines/mads/madsv2/core/general.h
    engines/mads/madsv2/core/image.h
    engines/mads/madsv2/core/pack.h
    engines/mads/madsv2/core/room.h
    engines/mads/madsv2/core/speech.cpp
    engines/mads/madsv2/core/sprite.h
    engines/mads/madsv2/core/text.h
    engines/mads/madsv2/core/tile.h


diff --git a/engines/mads/madsv2/core/anim.h b/engines/mads/madsv2/core/anim.h
index 98c4ecbbb3e..b385b193f10 100644
--- a/engines/mads/madsv2/core/anim.h
+++ b/engines/mads/madsv2/core/anim.h
@@ -239,7 +239,7 @@ struct ImageInter {
 	byte y;
 	// byte padding
 
-	static constexpr int SIZE = 2 + 1 + 1 + 1 + 1 + 2 + 1 + 1;
+	static constexpr size_t SIZE = 2 + 1 + 1 + 1 + 1 + 2 + 1 + 1;
 	void load(Common::SeekableReadStream *src);
 };
 typedef ImageInter *ImageInterPtr;
@@ -284,7 +284,7 @@ struct Frame {
 	int8 yank_x;        /* for backgrounds which wrap around, like starfields */
 	int8 yank_y;
 
-	static constexpr int SIZE = 1 + 1 + 2 + 2 + 2 + 1 + 1;
+	static constexpr size_t SIZE = 1 + 1 + 2 + 2 + 2 + 1 + 1;
 	void load(Common::SeekableReadStream *src);
 };
 typedef Frame *FramePtr;
@@ -301,7 +301,7 @@ struct SegmentInter {
 	byte sound;
 	int16 sound_frame;
 
-	static constexpr int SIZE = 5 * 2 + AA_MAX_SPAWNED + AA_MAX_SPAWNED * 2 + 1 + 2;
+	static constexpr size_t SIZE = 5 * 2 + AA_MAX_SPAWNED + AA_MAX_SPAWNED * 2 + 1 + 2;
 	void load(Common::SeekableReadStream *src);
 };
 typedef SegmentInter *SegmentInterPtr;
@@ -324,7 +324,7 @@ struct Speech {
 	int16 last_frame;             /* Last frame of segment    */
 	int16 first_image;            /* First image number       */
 
-	static constexpr int SIZE = 2 + 60 + 3 + 1 + 4 + 2 + 2 + 2 + 2 * RGBcolor::SIZE + 7 * 2;
+	static constexpr size_t SIZE = 2 + 60 + 3 + 1 + 4 + 2 + 2 + 2 + 2 * RGBcolor::SIZE + 7 * 2;
 	void load(Common::SeekableReadStream *src);
 };
 
@@ -388,7 +388,7 @@ struct AnimFile {
 	char speech_file[13];
 	char font_file[13];
 
-	static constexpr int SIZE = (8 * 2) + (10 * 2) + 13 +
+	static constexpr size_t SIZE = (8 * 2) + (10 * 2) + 13 +
 		(AA_MAX_SERIES * 13) + 13 + 13 + 13 + 13 +
 		1; // structure padding
 	void load(Common::SeekableReadStream *src);
diff --git a/engines/mads/madsv2/core/color.h b/engines/mads/madsv2/core/color.h
index e1d0cfc3f38..a70d1fc61ee 100644
--- a/engines/mads/madsv2/core/color.h
+++ b/engines/mads/madsv2/core/color.h
@@ -67,7 +67,7 @@ struct Color {
 	byte cycle;         /* Color cycling handle        */
 	byte group;         /* Color grouping flags        */
 
-	static constexpr int SIZE = 1 + 1 + 1 + 1 + 1 + 1;
+	static constexpr size_t SIZE = 1 + 1 + 1 + 1 + 1 + 1;
 	void load(Common::SeekableReadStream *src);
 };
 
@@ -80,7 +80,7 @@ struct ColorList {
 	uint16 num_colors;
 	Color table[COLOR_MAX_USER_COLORS];
 
-	static constexpr int SIZE = 2 + (Color::SIZE * COLOR_MAX_USER_COLORS);
+	static constexpr size_t SIZE = 2 + (Color::SIZE * COLOR_MAX_USER_COLORS);
 	bool load(Load &load_handle, int size);
 	void load(Common::SeekableReadStream *src);
 };
@@ -96,7 +96,7 @@ struct Cycle {
 	byte first_palette_color;           /* First color in final palette  */
 	byte ticks;                         /* 60/s ticks between cycles     */
 
-	static constexpr int SIZE = 1 + 1 + 1 + 1;
+	static constexpr size_t SIZE = 1 + 1 + 1 + 1;
 	void synchronize(Common::Serializer &s);
 };
 
@@ -109,7 +109,7 @@ struct CycleList {
 	int16 num_cycles;
 	Cycle table[COLOR_MAX_CYCLES];
 
-	static constexpr int SIZE = 2 + (Cycle::SIZE * COLOR_MAX_CYCLES);
+	static constexpr size_t SIZE = 2 + (Cycle::SIZE * COLOR_MAX_CYCLES);
 	void synchronize(Common::Serializer &s);
 	void load(Common::SeekableReadStream *src) {
 		Common::Serializer s(src, nullptr);
@@ -128,7 +128,7 @@ struct ShadowList {
 	uint16 num_shadow_colors;
 	int shadow_color[COLOR_MAX_SHADOW_COLORS];
 
-	static constexpr int SIZE = 2 + (2 * COLOR_MAX_SHADOW_COLORS);
+	static constexpr size_t SIZE = 2 + (2 * COLOR_MAX_SHADOW_COLORS);
 	void load(Common::SeekableReadStream *src);
 };
 
diff --git a/engines/mads/madsv2/core/conv.h b/engines/mads/madsv2/core/conv.h
index 82dd63b0ebd..9827c23cbd0 100644
--- a/engines/mads/madsv2/core/conv.h
+++ b/engines/mads/madsv2/core/conv.h
@@ -69,7 +69,7 @@ struct ConvNode {
 	int16 field_6;
 	int16 field_8;
 
-	static constexpr int SIZE = 2 * 5;
+	static constexpr size_t SIZE = 2 * 5;
 	void load(Common::SeekableReadStream *src);
 };
 
@@ -79,7 +79,7 @@ struct ConvDialog {
 	int16 script_offset;
 	int16 script_size;
 
-	static constexpr int SIZE = 2 * 4;
+	static constexpr size_t SIZE = 2 * 4;
 	void load(Common::SeekableReadStream *src);
 };
 
@@ -90,7 +90,7 @@ struct ConvScriptParams {
 	int16 param1;
 	int16 param2;
 
-	static constexpr int SIZE = 2 + 1 + 1 + 2 + 2;
+	static constexpr size_t SIZE = 2 + 1 + 1 + 2 + 2;
 	void load(Common::SeekableReadStream *src);
 };
 
@@ -101,7 +101,7 @@ struct ConvVariable {
 	int16 val = 0, type = 0;
 	int16 *ptr;
 
-	static constexpr int SIZE = 2 * 3;
+	static constexpr size_t SIZE = 2 * 3;
 	void load(Common::SeekableReadStream *src);
 	void save(Common::WriteStream *dest) const;
 };
@@ -133,7 +133,7 @@ struct Conv {
 	Common::Array<byte> scripts;
 	Common::Array<uint16> textLines;
 
-	static constexpr int SIZE = (2 * 7 + 16 * 5 + 2 * 5 + 14 + 4 + 4) +
+	static constexpr size_t SIZE = (2 * 7 + 16 * 5 + 2 * 5 + 14 + 4 + 4) +
 		// Padding for pointers in original structure
 		4 * 6;
 	void load(Common::SeekableReadStream *src);
@@ -163,7 +163,7 @@ struct ConvData {
 	Common::Array<uint16> entryFlags;
 	Common::Array<ConvVariable> variables;
 
-	static constexpr int SIZE = 2 * 10 + 2 * 10 * 5 + 2 * 3;
+	static constexpr size_t SIZE = 2 * 10 + 2 * 10 * 5 + 2 * 3;
 	void load(Common::SeekableReadStream *src);
 	void save(Common::WriteStream *dest) const;
 };
diff --git a/engines/mads/madsv2/core/copy.h b/engines/mads/madsv2/core/copy.h
index d28dc9b50fa..fe619561e55 100644
--- a/engines/mads/madsv2/core/copy.h
+++ b/engines/mads/madsv2/core/copy.h
@@ -45,7 +45,7 @@ struct CopyProt {
 	int16 word_number;
 	char say[20];
 
-	static constexpr int SIZE = 1 + 2 + 2 + 2 + 20;
+	static constexpr size_t SIZE = 1 + 2 + 2 + 2 + 20;
 	void load(Common::SeekableReadStream *src);
 };
 
diff --git a/engines/mads/madsv2/core/general.h b/engines/mads/madsv2/core/general.h
index e44cadb92c0..8a682f16ce5 100644
--- a/engines/mads/madsv2/core/general.h
+++ b/engines/mads/madsv2/core/general.h
@@ -43,7 +43,7 @@ typedef uint16  word;            /* generic 16 bit data */
 struct RGBcolor {
 	byte r, g, b;
 
-	static constexpr int SIZE = 3;
+	static constexpr size_t SIZE = 3;
 	inline void load(Common::SeekableReadStream *src) {
 		r = src->readByte();
 		g = src->readByte();
diff --git a/engines/mads/madsv2/core/image.h b/engines/mads/madsv2/core/image.h
index cce3c1dbcd8..0aaa73a86c5 100644
--- a/engines/mads/madsv2/core/image.h
+++ b/engines/mads/madsv2/core/image.h
@@ -40,7 +40,7 @@ struct Image {
 	byte depth;
 	byte scale;
 
-	static constexpr int SIZE = 2 + 1 + 1 + 2 + 2 + 2 + 1 + 1;
+	static constexpr size_t SIZE = 2 + 1 + 1 + 2 + 2 + 2 + 1 + 1;
 	void load(Common::SeekableReadStream *src);
 };
 
diff --git a/engines/mads/madsv2/core/pack.h b/engines/mads/madsv2/core/pack.h
index 7b746e2685c..16de084344a 100644
--- a/engines/mads/madsv2/core/pack.h
+++ b/engines/mads/madsv2/core/pack.h
@@ -88,7 +88,7 @@ struct PackStrategy {
 	long compressed_size;
 
 	void load(Common::SeekableReadStream *src);
-	static constexpr int SIZE = 1 + 1 + 4 + 4;
+	static constexpr size_t SIZE = 1 + 1 + 4 + 4;
 };
 
 typedef PackStrategy *PackStrategyPtr;
@@ -101,7 +101,7 @@ struct PackList {
 	PackStrategy strategy[PACK_MAX_LIST_LENGTH];
 
 	bool load(Common::SeekableReadStream *src);
-	static constexpr int SIZE = PACK_HEADER + PackStrategy::SIZE * PACK_MAX_LIST_LENGTH;
+	static constexpr size_t SIZE = PACK_HEADER + PackStrategy::SIZE * PACK_MAX_LIST_LENGTH;
 };
 
 typedef PackList *PackListPtr;
diff --git a/engines/mads/madsv2/core/room.h b/engines/mads/madsv2/core/room.h
index c926a7e1637..ff3adb1a775 100644
--- a/engines/mads/madsv2/core/room.h
+++ b/engines/mads/madsv2/core/room.h
@@ -104,7 +104,7 @@ struct HotSpot {
 	int16 vocab;                          /* Vocabulary id of hotspot name */
 	int16 verb;                           /* Vocabulary id of default verb */
 
-	static constexpr int SIZE = 6 * 2 + (5 * 1) + 1 + 2 + 2;
+	static constexpr size_t SIZE = 6 * 2 + (5 * 1) + 1 + 2 + 2;
 	void load(Common::SeekableReadStream *src);
 };
 
@@ -117,7 +117,7 @@ struct Rail {
 	int16 x, y;                           /* Screen location of node         */
 	word weight[ROOM_MAX_RAILS + 2];    /* Distance to other nodes in room */
 
-	static constexpr int SIZE = 2 + 2 + 2 * (ROOM_MAX_RAILS + 2);
+	static constexpr size_t SIZE = 2 + 2 + 2 * (ROOM_MAX_RAILS + 2);
 	void load(Common::SeekableReadStream *src);
 };
 
@@ -200,7 +200,7 @@ struct RoomFile {
 
 	ShadowList shadow;               /* Shadow list                   */
 
-	static constexpr int SIZE = 80 + (2 * 10) + 2 + 2 + 2 + (2 + 2) + (2 + 2) + 2 * 16 +
+	static constexpr size_t SIZE = 80 + (2 * 10) + 2 + 2 + 2 + (2 + 2) + (2 + 2) + 2 * 16 +
 		(Rail::SIZE * ROOM_MAX_RAILS) + ShadowList::SIZE;
 	void load(Common::SeekableReadStream *src);
 };
diff --git a/engines/mads/madsv2/core/speech.cpp b/engines/mads/madsv2/core/speech.cpp
index 13751331a6b..c6942117e3f 100644
--- a/engines/mads/madsv2/core/speech.cpp
+++ b/engines/mads/madsv2/core/speech.cpp
@@ -45,7 +45,7 @@ struct SpeechDir {
 	int32 size = 0;
 	int32 offset = 0;
 
-	static constexpr int SIZE = 2 + 2 + 2 + 2 + 2 + 4 + 4;
+	static constexpr size_t SIZE = 2 + 2 + 2 + 2 + 2 + 4 + 4;
 	void load(Common::SeekableReadStream *src);
 };
 
diff --git a/engines/mads/madsv2/core/sprite.h b/engines/mads/madsv2/core/sprite.h
index 3daef611050..5d9ca54094e 100644
--- a/engines/mads/madsv2/core/sprite.h
+++ b/engines/mads/madsv2/core/sprite.h
@@ -96,7 +96,7 @@ struct WalkerInfo {
 	byte   frame_rate;                    /* Frame rate for walker             */
 	byte   center_of_gravity;             /* Center of gravity displacement    */
 
-	static constexpr int SIZE = 2 + 2 + (2 + 2 + 2) * MAX_SECONDARY + 2 + 1 + 1;
+	static constexpr size_t SIZE = 2 + 2 + (2 + 2 + 2) * MAX_SECONDARY + 2 + 1 + 1;
 	void load(Load &load_handle);
 	void load(Common::SeekableReadStream *src);
 };
@@ -169,7 +169,7 @@ struct FileSprite {
 	int16 x, y;
 	int16 xs, ys;
 
-	static constexpr int SIZE = 4 + 4 + 2 + 2 + 2 + 2;
+	static constexpr size_t SIZE = 4 + 4 + 2 + 2 + 2 + 2;
 	void load(Common::SeekableReadStream *src);
 };
 
diff --git a/engines/mads/madsv2/core/text.h b/engines/mads/madsv2/core/text.h
index b7be1c202db..58ecb33533f 100644
--- a/engines/mads/madsv2/core/text.h
+++ b/engines/mads/madsv2/core/text.h
@@ -87,7 +87,7 @@ struct TextDirectory {
 	uint32 file_offset;
 	word length;
 
-	static constexpr int SIZE = 4 + 4 + 2;
+	static constexpr size_t SIZE = 4 + 4 + 2;
 	void load(Common::SeekableReadStream *src) {
 		src->readMultipleLE(id, file_offset, length);
 	}
diff --git a/engines/mads/madsv2/core/tile.h b/engines/mads/madsv2/core/tile.h
index 836545ca289..dd5ab267660 100644
--- a/engines/mads/madsv2/core/tile.h
+++ b/engines/mads/madsv2/core/tile.h
@@ -52,7 +52,7 @@ struct TileResource {
 
 	byte *tile_data;      /* Flat tile store allocated by tile_load (not serialised) */
 
-	static constexpr int SIZE = 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 2;
+	static constexpr size_t SIZE = 2 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 2;
 	void load(Common::SeekableReadStream *src);
 };
 
@@ -90,7 +90,7 @@ struct TileMapHeader {
 
 	int16 *map;                   /* Picture tile map pointer (not in size) */
 
-	static constexpr int SIZE = (14 * 2) + (8 * 2) + 4 + 4;
+	static constexpr size_t SIZE = (14 * 2) + (8 * 2) + 4 + 4;
 	void load(Common::SeekableReadStream *src);
 };
 


Commit: 1f3f425ddc42a022e0f610776ceca703fe73b4c6
    https://github.com/scummvm/scummvm/commit/1f3f425ddc42a022e0f610776ceca703fe73b4c6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-07-06T11:05:31+10:00

Commit Message:
MADS: Delete remove file call

Changed paths:
    engines/mads/madsv2/core/buffer.cpp
    engines/mads/madsv2/core/buffer.h


diff --git a/engines/mads/madsv2/core/buffer.cpp b/engines/mads/madsv2/core/buffer.cpp
index 9ac20646424..e75d062c52d 100644
--- a/engines/mads/madsv2/core/buffer.cpp
+++ b/engines/mads/madsv2/core/buffer.cpp
@@ -781,7 +781,8 @@ void buffer_restore(Buffer *source, int preserve_handle, int target_ems_handle,
 	case BUFFER_PRESERVED_CONVENTIONAL:
 		buffer_rect_copy_2(buffer_preserve_conventional, *source,
 			0, 0, x, y, xs, ys);
-		if (!buffer_restore_keep_flag) buffer_free(&buffer_preserve_conventional);
+		if (!buffer_restore_keep_flag)
+			buffer_free(&buffer_preserve_conventional);
 		break;
 
 	case BUFFER_PRESERVED_DISK:
@@ -794,7 +795,7 @@ void buffer_restore(Buffer *source, int preserve_handle, int target_ems_handle,
 	case BUFFER_PRESERVED_DISK - 7:
 	case BUFFER_PRESERVED_DISK - 8:
 	case BUFFER_PRESERVED_DISK - 9:
-		buffer_from_disk(source, neg(preserve_handle - BUFFER_PRESERVED_DISK), buffer_restore_keep_flag, x, y, xs, ys);
+		buffer_from_disk(source, neg(preserve_handle - BUFFER_PRESERVED_DISK), x, y, xs, ys);
 		break;
 
 	case BUFFER_NOT_PRESERVED:
@@ -937,7 +938,7 @@ done:
 	return buffer_id;
 }
 
-void buffer_from_disk(Buffer *source, int buffer_id, int keep_flag, int x, int y, int xs, int ys) {
+void buffer_from_disk(Buffer *source, int buffer_id, int x, int y, int xs, int ys) {
 	Common::InSaveFile *handle = nullptr;
 	byte *scan;
 	int count;
@@ -955,13 +956,8 @@ void buffer_from_disk(Buffer *source, int buffer_id, int keep_flag, int x, int y
 	}
 
 done:
-	if (handle != NULL) {
+	if (handle != NULL)
 		delete handle;
-		if (!keep_flag) {
-			buffer_tracking[buffer_id] = 0;
-			remove(file_name);
-		}
-	}
 }
 
 } // namespace MADSV2
diff --git a/engines/mads/madsv2/core/buffer.h b/engines/mads/madsv2/core/buffer.h
index d946d6de1df..a7c861d121f 100644
--- a/engines/mads/madsv2/core/buffer.h
+++ b/engines/mads/madsv2/core/buffer.h
@@ -241,10 +241,8 @@ extern void buffer_peel_horiz(Buffer *target, int peel);
 extern void buffer_peel_vert(Buffer *target, int peel,
 	byte *work_memory, long work_size);
 
-extern int buffer_to_disk(Buffer *source, int x, int y,
-	int xs, int ys);
-extern void buffer_from_disk(Buffer *source, int buffer_id,
-	int keep_flag, int x, int y, int xs, int ys);
+extern int buffer_to_disk(Buffer *source, int x, int y, int xs, int ys);
+extern void buffer_from_disk(Buffer *source, int buffer_id, int x, int y, int xs, int ys);
 
 extern bool buffer_to_ems(Buffer *source, int page_handle,
 	int source_ems_handle, int x, int y, int xs, int ys);


Commit: 99335c47f9ee928ea37f1192acbe534d6ab3a86b
    https://github.com/scummvm/scummvm/commit/99335c47f9ee928ea37f1192acbe534d6ab3a86b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-07-06T11:05:31+10:00

Commit Message:
MADS: Fixing Coverity warnings

Changed paths:
    engines/mads/madsv2/core/camera.cpp
    engines/mads/madsv2/core/conv.cpp


diff --git a/engines/mads/madsv2/core/camera.cpp b/engines/mads/madsv2/core/camera.cpp
index c99479bafa3..29303e833a6 100644
--- a/engines/mads/madsv2/core/camera.cpp
+++ b/engines/mads/madsv2/core/camera.cpp
@@ -122,6 +122,7 @@ static int camera_pan(Camera *camera, int *picture_view, int *player_loc,
 				}
 			}
 		} else {
+			assert(player_loc);
 
 			if (!camera->panning) {
 				low_edge = *picture_view + camera->pan_on_tolerance;
diff --git a/engines/mads/madsv2/core/conv.cpp b/engines/mads/madsv2/core/conv.cpp
index dfea6eee739..9d29bb2a41a 100644
--- a/engines/mads/madsv2/core/conv.cpp
+++ b/engines/mads/madsv2/core/conv.cpp
@@ -130,9 +130,12 @@ void ConvVariable::load(Common::SeekableReadStream *src) {
 			break;
 		case PTRTYPE_CONV_CONTROL:
 			if (val >= 0 && val < 20) {
-				// Index into one of the sequential 5 element arrays:
+				// Index into one of the four 5-element arrays in turn:
 				// speaker_frame[5], x[5], y[5], width[5]
-				ptr = conv_control.speaker_frame + val;
+				int16 *const fieldArrays[] = {
+					conv_control.speaker_frame, conv_control.x, conv_control.y, conv_control.width
+				};
+				ptr = &fieldArrays[val / CONV_MAX_DATA][val % CONV_MAX_DATA];
 			} else if (val == 20) {
 				ptr = &conv_control.speaker_val;
 			} else {
@@ -596,7 +599,7 @@ static void conv_generate_text(Conv *convIn, ConvData * /*convData*/,
 
 		// Size and position the popup from the current speaker's slot data.
 		int horiz_pieces = popup_estimate_pieces(conv_control.width[person]);
-		popup_create(horiz_pieces,
+		(void)popup_create(horiz_pieces,
 			conv_control.x[person],
 			conv_control.y[person]);
 
@@ -815,10 +818,10 @@ static int16 conv_param_evaluate(ConvScriptParams *params) {
 		result = param1 * param2;
 		break;
 	case CONV_OP_DIV:
-		result = param1 / param2;
+		result = param2 ? param1 / param2 : 0;
 		break;
 	case CONV_OP_MOD:
-		result = param1 % param2;
+		result = param2 ? param1 % param2 : 0;
 		break;
 	case CONV_OP_GE:
 		result = (param1 >= param2) ? 1 : 0;
@@ -1187,7 +1190,7 @@ void conv_start(ConvData *convData, Conv *convIn) {
 	// Resolve the byte-offset sub-array pointers stored in the ConvData block
 	conv_imports = convData->imports.empty() ? nullptr : &convData->imports[0];
 	conv_entry_flags = convData->entryFlags.empty() ? nullptr : & convData->entryFlags[0];
-	conv_varsDataPtr = convData->variables.empty() ? nullptr : & convData->variables[0];
+	conv_varsDataPtr = &convData->variables[0];
 
 	// conv_vars0ValPtr -> variables[0].val (skips the isPtr field)
 	conv_vars0ValPtr   = &conv_varsDataPtr[0].val;
@@ -1290,12 +1293,18 @@ void conv_run(int convId) {
 
 	// Bind conv variables 2–22 to live ConvControl fields.
 	// Variable 2 maps to speaker_val (not contiguous with the arrays below).
-	// Variables 3–22 map to speaker_frame[5], x[5], y[5], width[5] — 20
-	// consecutive int16s — so a single pointer walk replaces 20 separate calls.
+	// Variables 3–22 map to speaker_frame[5], x[5], y[5], width[5] in turn.
 	conv_set_variable(2, &conv_control.speaker_val);
-	int16 *p = conv_control.speaker_frame;
-	for (int i = 3; i <= 22; ++i, ++p)
-		conv_set_variable(i, p);
+
+	int16 *const fieldArrays[] = {
+		conv_control.speaker_frame, conv_control.x, conv_control.y, conv_control.width
+	};
+
+	int varIdx = 3;
+	for (int16 *field : fieldArrays) {
+		for (int j = 0; j < CONV_MAX_DATA; ++j)
+			conv_set_variable(varIdx++, &field[j]);
+	}
 
 	// Load speaker portrait series for each declared speaker
 	for (idx = 0; idx < conv[slot]->speaker_count; ++idx) {


Commit: d1c0aae1e17eeec4f4c96780445b05ca0fe4ebe0
    https://github.com/scummvm/scummvm/commit/d1c0aae1e17eeec4f4c96780445b05ca0fe4ebe0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-07-06T11:05:31+10:00

Commit Message:
MADS: Fixing dialog Coverity warnings

Changed paths:
    engines/mads/madsv2/core/dialog.cpp


diff --git a/engines/mads/madsv2/core/dialog.cpp b/engines/mads/madsv2/core/dialog.cpp
index 837b164f6a9..5e473ff5074 100644
--- a/engines/mads/madsv2/core/dialog.cpp
+++ b/engines/mads/madsv2/core/dialog.cpp
@@ -674,74 +674,68 @@ DialogPtr dialog_create(DialogPtr dialog, int ul_x, int ul_y, int width,
 	mouse_callback = NULL;
 	page_callback = NULL;
 
-	if (dialog != NULL) {
-
+	if (dialog->string_space == NULL) {
+		dialog->status |= DD_DYNAMICSTRINGS;
+		dialog->string_space = (char *)mem_get(dialog_string_space);
+		dialog->string_space_remaining = dialog_string_space;
 		if (dialog->string_space == NULL) {
-			dialog->status |= DD_DYNAMICSTRINGS;
-			dialog->string_space = (char *)mem_get(dialog_string_space);
-			dialog->string_space_remaining = dialog_string_space;
-			if (dialog->string_space == NULL) {
-				dialog_error = DD_ERR_NOMOREMEMORY;
-				if (dialog->status & DD_DYNAMIC) {
-					mem_free(dialog);
-				}
-				dialog = NULL;
+			dialog_error = DD_ERR_NOMOREMEMORY;
+			if (dialog->status & DD_DYNAMIC) {
+				mem_free(dialog);
 			}
+			return nullptr;
 		}
+	}
 
-		if (normal_color == DD_DEFAULT) {
-			dialog->normal_color = dialog_default_normal;
-		} else {
-			dialog->normal_color = normal_color;
-		}
+	if (normal_color == DD_DEFAULT) {
+		dialog->normal_color = dialog_default_normal;
+	} else {
+		dialog->normal_color = normal_color;
+	}
 
-		if (select_color == DD_DEFAULT) {
-			dialog->select_color = dialog_default_select;
-		} else {
-			dialog->select_color = select_color;
-		}
+	if (select_color == DD_DEFAULT) {
+		dialog->select_color = dialog_default_select;
+	} else {
+		dialog->select_color = select_color;
+	}
 
-		if (hilite_color == DD_DEFAULT) {
-			if (screen_video_mode == mono_text_mode) {
-				dialog->hilite_color = dialog_default_select;
-			} else {
-				dialog->hilite_color = dialog_default_hilite;
-			}
+	if (hilite_color == DD_DEFAULT) {
+		if (screen_video_mode == mono_text_mode) {
+			dialog->hilite_color = dialog_default_select;
 		} else {
-			dialog->hilite_color = hilite_color;
+			dialog->hilite_color = dialog_default_hilite;
 		}
+	} else {
+		dialog->hilite_color = hilite_color;
+	}
 
-		dialog->width = width;
-
-		window_set(&dialog->window, ul_x, ul_y, ul_x + width + 1, ul_y);
+	dialog->width = width;
 
-		dialog->base_x = ul_x + 1;
-		dialog->base_y = ul_y + 1;
+	window_set(&dialog->window, ul_x, ul_y, ul_x + width + 1, ul_y);
 
-		dialog->num_items = 0;
-		dialog->fill_marker = 0;
-		dialog->active_button = dialog->active_item = 0;
+	dialog->base_x = ul_x + 1;
+	dialog->base_y = ul_y + 1;
 
-		dialog->cursor_x = dialog->cursor_y = 0;
+	dialog->num_items = 0;
+	dialog->fill_marker = 0;
+	dialog->active_button = dialog->active_item = 0;
 
-		dialog->button_left = 1;
-		dialog->button_right = 0;
+	dialog->cursor_x = dialog->cursor_y = 0;
 
-		dialog->buffers_allocated = 0;
-		dialog->lists_allocated = 0;
+	dialog->button_left = 1;
+	dialog->button_right = 0;
 
-		dialog->callback = NULL;
-		dialog->checkbox_callback = NULL;
+	dialog->buffers_allocated = 0;
+	dialog->lists_allocated = 0;
 
-		dialog->cancel_item = NULL;
-		dialog->path_item = NULL;
-		dialog->default_item = NULL;
+	dialog->callback = NULL;
+	dialog->checkbox_callback = NULL;
 
-		dialog->string_marker = dialog->string_space;
+	dialog->cancel_item = NULL;
+	dialog->path_item = NULL;
+	dialog->default_item = NULL;
 
-	} else {
-		dialog_error = DD_ERR_NOMOREMEMORY;
-	}
+	dialog->string_marker = dialog->string_space;
 
 	return  dialog;
 }


Commit: 0e25f15218f2dea2a09ec3d5667f0db22823b1bd
    https://github.com/scummvm/scummvm/commit/0e25f15218f2dea2a09ec3d5667f0db22823b1bd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-07-06T11:05:32+10:00

Commit Message:
MADS: Fixing env Coverity warnings

Changed paths:
    engines/mads/madsv2/core/env.cpp


diff --git a/engines/mads/madsv2/core/env.cpp b/engines/mads/madsv2/core/env.cpp
index add1511c1c6..c95653e2728 100644
--- a/engines/mads/madsv2/core/env.cpp
+++ b/engines/mads/madsv2/core/env.cpp
@@ -90,6 +90,7 @@ char *env_catint(char *out, int value, int digits) {
 
 	for (mark = strlen(out) - digits; (unsigned)mark < strlen(out); mark++) {
 		if (value >= power) {
+			assert(power != 0);
 			digit = value / power;
 			value = value - (digit * power);
 			out[mark] += digit;
@@ -359,9 +360,7 @@ Common::SeekableReadStream *env_open(const char *filename, const char *options)
 
 			if (fileio_exist(load_file)) {
 				Common::File *f = new Common::File();
-				f->open(load_file);
-
-				if (handle == NULL) {
+				if (!f->open(load_file)) {
 					delete f;
 					goto done;
 				}


Commit: 5c7f609037739807e2f92dafb59a7aed00b59db1
    https://github.com/scummvm/scummvm/commit/5c7f609037739807e2f92dafb59a7aed00b59db1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-07-06T11:05:32+10:00

Commit Message:
MADS: Fixing game Coverity warnings

Changed paths:
    engines/mads/madsv2/core/game.cpp


diff --git a/engines/mads/madsv2/core/game.cpp b/engines/mads/madsv2/core/game.cpp
index e6c7fc38a46..70881c795a8 100644
--- a/engines/mads/madsv2/core/game.cpp
+++ b/engines/mads/madsv2/core/game.cpp
@@ -310,7 +310,6 @@ void flag_parse(const char **myscan) {
 	case 'M':
 		if (scan_past(myscan, ':')) {
 			mem_max = atol(*myscan);
-			mem_get_name(mem_max, "$HIDE$");
 			scan_past(myscan, 0);
 		}
 		break;
@@ -2285,7 +2284,7 @@ static void game_global_update() {
 
 	debugger_name("4", 23);
 
-	for (count = 0; count < 220; count += 10) {
+	for (count = 0; count < GLOBAL_LIST_SIZE; count += 10) {
 		screen_printf(0, (count / 10) + 2, "%4d => %04x  %04x  %04x  %04x  %04x  %04x  %04x  %04x  %04x  %04x",
 			count,
 			global[count],
@@ -2453,7 +2452,6 @@ static void game_matte() {
 					Common::sprintf_s(sprite_buf, "%d", image_list[count].sprite_id);
 				}
 			} else {
-				series_id = -1;
 				Common::strcpy_s(name_buf, "sys");
 				Common::strcpy_s(sprite_buf, " ");
 			}


Commit: 88816ce32f460130aff0f8044732e81bbcd2bf4e
    https://github.com/scummvm/scummvm/commit/88816ce32f460130aff0f8044732e81bbcd2bf4e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2026-07-06T11:05:32+10:00

Commit Message:
MADS: Fixing inter/kernel Coverity warnings

Changed paths:
    engines/mads/madsv2/core/himem.cpp
    engines/mads/madsv2/core/inter.cpp
    engines/mads/madsv2/core/kernel.cpp
    engines/mads/madsv2/core/keys.cpp


diff --git a/engines/mads/madsv2/core/himem.cpp b/engines/mads/madsv2/core/himem.cpp
index 0f9d326c172..865361fdc15 100644
--- a/engines/mads/madsv2/core/himem.cpp
+++ b/engines/mads/madsv2/core/himem.cpp
@@ -140,9 +140,7 @@ int himem_resident(const char *filename) {
 	}
 
 	for (count = 0; (count < HIMEM_MAX_RESIDENT) && (id < 0); count++) {
-		if (himem_directory[count].memory_type == MEM_NONE) {
-			if (filename == NULL) id = count;
-		} else {
+		if (himem_directory[count].memory_type != MEM_NONE) {
 			if (scumm_stricmp(mark, himem_directory[count].list) == 0) {
 				id = count;
 			}
diff --git a/engines/mads/madsv2/core/inter.cpp b/engines/mads/madsv2/core/inter.cpp
index 8e2be74a84a..271a37c5cef 100644
--- a/engines/mads/madsv2/core/inter.cpp
+++ b/engines/mads/madsv2/core/inter.cpp
@@ -420,7 +420,7 @@ done:
 static void inter_show_word(int class_, int id) {
 	int x, y, junk;
 	int word_id = 0;
-	char temp_buf[80];
+	char temp_buf[80] = { 0 };
 	int write_it = true;
 
 	if (!inter_get_spot(class_, id, &x, &y, &junk, &junk)) {
diff --git a/engines/mads/madsv2/core/kernel.cpp b/engines/mads/madsv2/core/kernel.cpp
index 42ba19a023f..93a73bb3935 100644
--- a/engines/mads/madsv2/core/kernel.cpp
+++ b/engines/mads/madsv2/core/kernel.cpp
@@ -2147,6 +2147,7 @@ static void kernel_message_update(KernelMessagePtr my_message) {
 	yy = 0;
 
 	if (my_message->flags & KERNEL_MESSAGE_ANIM) {
+		assert(imgList);
 		xx = imgList[image].x - picture_view_x;
 		yy = imgList[image].y - picture_view_y;
 	}
@@ -2394,10 +2395,13 @@ int  kernel_dynamic_consecutive(int id) {
 		}
 	}
 
-	if (id >= 0) scan = -1;
+	if (id >= 0) {
+		warning("kernel_dynamic_consecutive(%d) - could not find id", id);
+		scan = 0;
+	}
 
 done:
-	return (scan);
+	return scan;
 }
 
 void kernel_refresh_dynamic() {
@@ -2613,6 +2617,7 @@ void kernel_random_messages_init(int max_messages_at_once,
 		my_quote = va_arg(marker, int);
 	}
 
+	va_end(marker);
 	kernel_random_purge();
 }
 
diff --git a/engines/mads/madsv2/core/keys.cpp b/engines/mads/madsv2/core/keys.cpp
index 8bfc40fa42f..75ec128d2b0 100644
--- a/engines/mads/madsv2/core/keys.cpp
+++ b/engines/mads/madsv2/core/keys.cpp
@@ -78,7 +78,7 @@ int keys_read_buffer(KeyPtr key_buf) {
 	if (key_buf->len > 0) {
 		myval = key_buf->buf[0];
 		key_buf->len--;
-		memcpy(key_buf->buf, key_buf->buf + 1, (key_buf->len * sizeof(int)));
+		memmove(key_buf->buf, key_buf->buf + 1, (key_buf->len * sizeof(int)));
 
 		return myval;
 	} else {
@@ -97,7 +97,7 @@ int keys_append_buffer(KeyPtr key_buf, int newchar) {
 
 int keys_insert_buffer(KeyPtr key_buf, int newchar, int before) {
 	if ((key_buf->len < KEYS_MAX_BUF_CHARS) && (before < key_buf->len) && (before > 0)) {
-		memcpy(key_buf->buf + before + 1, key_buf->buf + before, (key_buf->len - before) * sizeof(int));
+		memmove(key_buf->buf + before + 1, key_buf->buf + before, (key_buf->len - before) * sizeof(int));
 		key_buf->buf[before] = newchar;
 		return (before + 1);
 	} else {




More information about the Scummvm-git-logs mailing list