[Scummvm-git-logs] scummvm master -> 0da56a136bd54e2a376374c52430e37825972933

Strangerke noreply at scummvm.org
Wed Mar 16 21:56:36 UTC 2022


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:
0da56a136b CHEWY: Fix some coverity issues


Commit: 0da56a136bd54e2a376374c52430e37825972933
    https://github.com/scummvm/scummvm/commit/0da56a136bd54e2a376374c52430e37825972933
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2022-03-16T22:56:17+01:00

Commit Message:
CHEWY: Fix some coverity issues

Changed paths:
    engines/chewy/atds.cpp
    engines/chewy/atds.h
    engines/chewy/object.cpp
    engines/chewy/object.h
    engines/chewy/object_extra.cpp
    engines/chewy/object_extra.h
    engines/chewy/resource.cpp
    engines/chewy/room.cpp


diff --git a/engines/chewy/atds.cpp b/engines/chewy/atds.cpp
index f8140de456e..536359ca998 100644
--- a/engines/chewy/atds.cpp
+++ b/engines/chewy/atds.cpp
@@ -89,7 +89,7 @@ bool AtsStrHeader::load(Common::SeekableReadStream *src) {
 
 
 Atdsys::Atdsys() {
-	SplitStringInit init_ssi = { nullptr, 0, 0, 220, 4, SPLIT_CENTER, 8, 8,};
+	SplitStringInit init_ssi = { nullptr, 0, 0, 220, 4, SPLIT_CENTER, 8, 8 };
 	_aadv._dialog = false;
 	_aadv._strNr = -1;
 	_aadv._silentCount = false;
@@ -115,6 +115,13 @@ Atdsys::Atdsys() {
 	_invUseMem = nullptr;
 
 	_dialogResource = new DialogResource(ADS_TXT_STEUER);
+
+	for (int i = 0; i < 4; ++i)
+		_ats_st_header[i] = nullptr;
+
+	_adsnb._blkNr = 0;
+	_adsnb._endNr = 0;
+	_adsStackPtr = 0;
 }
 
 Atdsys::~Atdsys() {
@@ -609,32 +616,31 @@ void Atdsys::print_ats(int16 x, int16 y, int16 scrX, int16 scrY) {
 
 		if (_atsv._silentCount <= 0) {
 			char *tmp_ptr = _atsv._ptr;
-			_atsSsi = _ssi[0];
-			_atsSsi._str = tmp_ptr;
-			_atsSsi.Fvorx = _G(fontMgr)->getFont()->getDataWidth();
-			_atsSsi.FHoehe = _G(fontMgr)->getFont()->getDataHeight();
-			_atsSsi._x = x - scrX;
-			_atsSsi._y = y - scrY;
+			SplitStringInit *_atsSsi = &_ssi[0];
+			_atsSsi->_str = tmp_ptr;
+			_atsSsi->Fvorx = _G(fontMgr)->getFont()->getDataWidth();
+			_atsSsi->FHoehe = _G(fontMgr)->getFont()->getDataHeight();
+			_atsSsi->_x = x - scrX;
+			_atsSsi->_y = y - scrY;
 			char *start_ptr = tmp_ptr;
 			str_null2leer(start_ptr, start_ptr + _atsv._txtLen - 1);
-			SplitStringInit tmp_ssi = _atsSsi;
-			_ssr = split_string(&tmp_ssi);
+			_ssr = split_string(_atsSsi);
 
 			for (int16 i = 0; i < _ssr->_nr; i++) {
 				_G(out)->printxy(_ssr->_x[i],
-				              _ssr->_y + (i * _atsSsi.FHoehe) + 1,
+				              _ssr->_y + (i * _atsSsi->FHoehe) + 1,
 				              0, 300, 0, _ssr->_strPtr[i]);
 				_G(out)->printxy(_ssr->_x[i],
-				              _ssr->_y + (i * _atsSsi.FHoehe) - 1,
+				              _ssr->_y + (i * _atsSsi->FHoehe) - 1,
 				              0, 300, 0, _ssr->_strPtr[i]);
 				_G(out)->printxy(_ssr->_x[i] + 1,
-				              _ssr->_y + (i * _atsSsi.FHoehe),
+				              _ssr->_y + (i * _atsSsi->FHoehe),
 				              0, 300, 0, _ssr->_strPtr[i]);
 				_G(out)->printxy(_ssr->_x[i] - 1,
-				              _ssr->_y + (i * _atsSsi.FHoehe),
+				              _ssr->_y + (i * _atsSsi->FHoehe),
 				              0, 300, 0, _ssr->_strPtr[i]);
 				_G(out)->printxy(_ssr->_x[i],
-				              _ssr->_y + (i * _atsSsi.FHoehe),
+				              _ssr->_y + (i * _atsSsi->FHoehe),
 				              _atsv._color,
 				              300, 0, _ssr->_strPtr[i]);
 				tmp_ptr += strlen(_ssr->_strPtr[i]) + 1;
diff --git a/engines/chewy/atds.h b/engines/chewy/atds.h
index dcc79117a43..fec5cb88e12 100644
--- a/engines/chewy/atds.h
+++ b/engines/chewy/atds.h
@@ -241,6 +241,14 @@ struct SplitStringRet {
 	int16 _y;
 	short _nr;
 	int16 _next;
+
+	SplitStringRet() {
+		_strPtr = nullptr;
+		_x = nullptr;
+		_y = 0;
+		_nr = 0;
+		_next = 0;
+	}
 };
 
 struct SplitStringInit {
@@ -362,8 +370,6 @@ private:
 		{ 0, 100, 0, 200, 4, SPLIT_CENTER, 8, 8 },
 	};
 
-	SplitStringInit _atsSsi;
-
 	char *_splitPtr[MAX_STR_SPLIT] = { nullptr };
 	int16 _splitX[MAX_STR_SPLIT] = { 0 };
 	int16 _invBlockNr;
diff --git a/engines/chewy/object.cpp b/engines/chewy/object.cpp
index 0e6aef75fe6..eced7999196 100644
--- a/engines/chewy/object.cpp
+++ b/engines/chewy/object.cpp
@@ -21,7 +21,6 @@
 
 #include "chewy/defines.h"
 #include "chewy/globals.h"
-#include "chewy/ngshext.h"
 #include "chewy/object.h"
 
 namespace Chewy {
@@ -69,10 +68,10 @@ Object::Object(Spieler *sp) {
 Object::~Object() {
 }
 
-int16 Object::load(const char *fname_, RoomMovObject *rmo) {
+int16 Object::load(const char *filename, RoomMovObject *rmo) {
 	Common::File f;
 
-	if (f.open(fname_)) {
+	if (f.open(filename)) {
 		if (!_iibFileHeader.load(&f)) {
 			error("Object::load error");
 		}
@@ -104,10 +103,10 @@ int16 Object::load(const char *fname_, RoomMovObject *rmo) {
 	return _maxInventoryObj;
 }
 
-int16 Object::load(const char *fname_, RoomStaticInventory *rsi) {
+int16 Object::load(const char *filename, RoomStaticInventory *rsi) {
 	Common::File f;
 
-	if (f.open(fname_)) {
+	if (f.open(filename)) {
 		if (!_sibFileHeader.load(&f)) {
 			error("Object::load error");
 		}
@@ -137,10 +136,10 @@ int16 Object::load(const char *fname_, RoomStaticInventory *rsi) {
 	return _maxStaticInventory;
 }
 
-int16 Object::load(const char *fname_, RoomExit *roomExit) {
+int16 Object::load(const char *filename, RoomExit *roomExit) {
 	Common::File f;
 
-	if (f.open(fname_)) {
+	if (f.open(filename)) {
 		if (!_eibFileHeader.load(&f)) {
 			error("Object::load error");
 		}
diff --git a/engines/chewy/object.h b/engines/chewy/object.h
index 83dac2c70c5..226308a35d8 100644
--- a/engines/chewy/object.h
+++ b/engines/chewy/object.h
@@ -39,9 +39,9 @@ public:
 	Object(Spieler *sp);
 	~Object();
 
-	short load(const char *fname, RoomMovObject *rmo);
-	int16 load(const char *fname, RoomStaticInventory *rsi);
-	int16 load(const char *fname, RoomExit *roomExit);
+	short load(const char *filename, RoomMovObject *rmo);
+	int16 load(const char *filename, RoomStaticInventory *rsi);
+	int16 load(const char *filename, RoomExit *roomExit);
 	void sort();
 	void free_inv_spr(byte **inv_spr_adr);
 	int16 is_sib_mouse(int16 mouse_x, int16 mouse_y);
diff --git a/engines/chewy/object_extra.cpp b/engines/chewy/object_extra.cpp
index 477e6e05af1..87e45cfdac4 100644
--- a/engines/chewy/object_extra.cpp
+++ b/engines/chewy/object_extra.cpp
@@ -58,6 +58,12 @@ bool IibFileHeader::load(Common::SeekableReadStream *src) {
 	return true;
 }
 
+IibFileHeader::IibFileHeader() {
+	memset(Id, 0, 4);
+	memset(Tafname, 14, 0);
+	Size = 0;
+}
+
 bool RoomStaticInventory::load(Common::SeekableReadStream *src) {
 	Common::Serializer s(src, nullptr);
 	synchronize(s);
diff --git a/engines/chewy/object_extra.h b/engines/chewy/object_extra.h
index 23c59c20399..b0ca69828bd 100644
--- a/engines/chewy/object_extra.h
+++ b/engines/chewy/object_extra.h
@@ -75,6 +75,7 @@ struct IibFileHeader {
 	uint32 Size;
 
 	bool load(Common::SeekableReadStream *src);
+	IibFileHeader();
 };
 
 struct RoomStaticInventory {
diff --git a/engines/chewy/resource.cpp b/engines/chewy/resource.cpp
index d86b66bed84..eeba93a1225 100644
--- a/engines/chewy/resource.cpp
+++ b/engines/chewy/resource.cpp
@@ -23,7 +23,6 @@
 #include "common/stream.h"
 #include "common/substream.h"
 #include "common/textconsole.h"
-#include "graphics/pixelformat.h"
 #include "graphics/surface.h"
 
 #include "chewy/atds.h"
@@ -116,15 +115,13 @@ uint8 *Resource::getChunkData(uint num) {
 }
 
 void Resource::initSprite(Common::String filename) {
-	uint32 nextSpriteOffset;
-
 	_resType = kResourceTAF;
 	_encrypted = false;
 	/*screenMode = */_stream.readUint16LE();
 	_chunkCount = _stream.readUint16LE();
 	_allSize = _stream.readUint32LE();
 	_stream.read(_spritePalette, 3 * 256);
-	nextSpriteOffset = _stream.readUint32LE();
+	uint32 nextSpriteOffset = _stream.readUint32LE();
 	_spriteCorrectionsCount = _stream.readUint16LE();
 
 	// Sometimes there's a filler byte
@@ -166,13 +163,11 @@ void Resource::initSprite(Common::String filename) {
 }
 
 void Resource::unpackRLE(uint8 *buffer, uint32 compressedSize, uint32 uncompressedSize) {
-	uint8 count;
-	uint8 value;
 	uint32 outPos = 0;
 
 	for (uint i = 0; i < (compressedSize) / 2 && outPos < uncompressedSize; i++) {
-		count = _stream.readByte();
-		value = _stream.readByte();
+		uint8 count = _stream.readByte();
+		uint8 value = _stream.readByte();
 		for (uint8 j = 0; j < count && outPos < uncompressedSize; j++) {
 			buffer[outPos++] = value;
 		}
diff --git a/engines/chewy/room.cpp b/engines/chewy/room.cpp
index 1c07fa480db..5265a6fa712 100644
--- a/engines/chewy/room.cpp
+++ b/engines/chewy/room.cpp
@@ -151,6 +151,7 @@ Room::Room() {
 	init_ablage();
 	for (int16 i = 0; i < MAX_ROOM_HANDLE; i++)
 		_roomHandle[i] = nullptr;
+	_roomInfo = nullptr;
 }
 
 Room::~Room() {




More information about the Scummvm-git-logs mailing list