[Scummvm-cvs-logs] SF.net SVN: scummvm:[55369] scummvm/trunk/engines/parallaction

tdhs at users.sourceforge.net tdhs at users.sourceforge.net
Fri Jan 21 04:25:01 CET 2011


Revision: 55369
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55369&view=rev
Author:   tdhs
Date:     2011-01-21 03:25:01 +0000 (Fri, 21 Jan 2011)

Log Message:
-----------
PARALLACTION: Fix Un-initialized Memory Errors and Leaks in Nippon Safes Amiga Demo.

These were found using Valgrind.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/disk_ns.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp

Modified: scummvm/trunk/engines/parallaction/disk_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_ns.cpp	2011-01-21 01:58:53 UTC (rev 55368)
+++ scummvm/trunk/engines/parallaction/disk_ns.cpp	2011-01-21 03:25:01 UTC (rev 55369)
@@ -854,6 +854,7 @@
 Common::SeekableReadStream *AmigaDisk_ns::tryOpenFile(const char* name) {
 	debugC(3, kDebugDisk, "AmigaDisk_ns::tryOpenFile(%s)", name);
 
+	PowerPackerStream *ret;
 	Common::SeekableReadStream *stream = _sset.createReadStreamForMember(name);
 	if (stream)
 		return stream;
@@ -861,13 +862,19 @@
 	char path[PATH_LEN];
 	sprintf(path, "%s.pp", name);
 	stream = _sset.createReadStreamForMember(path);
-	if (stream)
-		return new PowerPackerStream(*stream);
+	if (stream) {
+		ret = new PowerPackerStream(*stream);
+		delete stream;
+		return ret;
+	}
 
 	sprintf(path, "%s.dd", name);
 	stream = _sset.createReadStreamForMember(path);
-	if (stream)
-		return new PowerPackerStream(*stream);
+	if (stream) {
+		ret = new PowerPackerStream(*stream);
+		delete stream;
+		return ret;
+	}
 
 	return 0;
 }

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2011-01-21 01:58:53 UTC (rev 55368)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2011-01-21 03:25:01 UTC (rev 55369)
@@ -39,21 +39,16 @@
 #include "parallaction/sound.h"
 #include "parallaction/walk.h"
 
-
-
 namespace Parallaction {
-
 Parallaction *_vm = NULL;
 // public stuff
 
 char		_saveData1[30] = { '\0' };
 uint32		_engineFlags = 0;
-
 uint32		_globalFlags = 0;
 
 // private stuff
 
-
 Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc) :
 	Engine(syst), _gameDescription(gameDesc), _location(getGameType()),
 	_dialogueMan(0) {
@@ -73,7 +68,6 @@
 	g_eventRec.registerRandomSource(_rnd, "parallaction");
 }
 
-
 Parallaction::~Parallaction() {
 	delete _debugger;
 	delete _globalFlagsNames;
@@ -98,9 +92,7 @@
 	delete _input;
 }
 
-
 Common::Error Parallaction::init() {
-	
 	_gameType = getGameType();
 	_engineFlags = 0;
 	_objectsNames = NULL;
@@ -119,6 +111,7 @@
 
 	strcpy(_characterName1, "null");
 
+	memset(_localFlags, 0, sizeof(_localFlags));
 	memset(_locationNames, 0, NUM_LOCATIONS * 32);
 
 	// this needs _disk to be already setup
@@ -158,8 +151,6 @@
 	_system->delayMillis(30);
 }
 
-
-
 void Parallaction::pauseJobs() {
 	debugC(9, kDebugExec, "pausing jobs execution");
 
@@ -182,7 +173,6 @@
 	return AnimationPtr();
 }
 
-
 void Parallaction::allocateLocationSlot(const char *name) {
 	// WORKAROUND: the original code erroneously incremented
 	// _currentLocationIndex, thus producing inconsistent
@@ -213,7 +203,6 @@
 	}
 }
 
-
 Location::Location(int gameType) : _gameType(gameType) {
 	cleanup(true);
 }
@@ -253,7 +242,6 @@
 	return scale;
 }
 
-
 void Parallaction::showSlide(const char *name, int x, int y) {
 	BackgroundInfo *info = new BackgroundInfo;
 	_disk->loadSlide(*info, name);
@@ -264,7 +252,6 @@
 	_gfx->setBackground(kBackgroundSlide, info);
 }
 
-
 void Parallaction::showLocationComment(const Common::String &text, bool end) {
 	_balloonMan->setLocationBalloon(text.c_str(), end);
 }
@@ -296,7 +283,6 @@
 }
 
 void Parallaction::runGame() {
-
 	int event = _input->updateInput();
 	if (shouldQuit())
 		return;
@@ -326,9 +312,6 @@
 	updateView();
 }
 
-
-
-
 //	displays transition before a new location
 //
 //	clears screen (in white??)
@@ -371,8 +354,6 @@
 	_gfx->setPalette(_gfx->_palette);
 
 	debugC(2, kDebugExec, "doLocationEnterTransition completed");
-
-	return;
 }
 
 void Parallaction::setLocationFlags(uint32 flags) {
@@ -391,8 +372,6 @@
 	return _localFlags[_currentLocationIndex];
 }
 
-
-
 void Parallaction::drawAnimation(AnimationPtr anim) {
 	if ((anim->_flags & kFlagsActive) == 0)   {
 		return;
@@ -485,7 +464,6 @@
 	debugC(9, kDebugExec, "Parallaction::updateZones done()\n");
 }
 
-
 void Parallaction::showZone(ZonePtr z, bool visible) {
 	if (!z) {
 		return;
@@ -503,10 +481,7 @@
 	}
 }
 
-
-//
 //	ZONE TYPE: EXAMINE
-//
 
 void Parallaction::enterCommentMode(ZonePtr z) {
 	if (!z) {
@@ -568,7 +543,6 @@
 	}
 }
 
-
 void Parallaction::runZone(ZonePtr z) {
 	debugC(3, kDebugExec, "runZone (%s)", z->_name);
 
@@ -617,9 +591,8 @@
 	return;
 }
 
-//
 //	ZONE TYPE: DOOR
-//
+
 void Parallaction::updateDoor(ZonePtr z, bool close) {
 	z->_flags = close ? (z->_flags |= kFlagsClosed) : (z->_flags &= ~kFlagsClosed);
 
@@ -632,11 +605,7 @@
 	return;
 }
 
-
-
-//
 //	ZONE TYPE: GET
-//
 
 bool Parallaction::pickupItem(ZonePtr z) {
 	if (z->_flags & kFlagsFixed) {
@@ -692,7 +661,7 @@
 bool Parallaction::checkZoneType(ZonePtr z, uint32 type) {
 	if (_gameType == GType_Nippon) {
 		if ((type == 0) && (ITEMTYPE(z) == 0))
-			return true;		
+			return true;
 	}
 
 	if (_gameType == GType_BRA) {
@@ -765,11 +734,10 @@
 	return checkZoneType(z, type);
 }
 
-/* NOTE: hitZone needs to be passed absolute game coordinates to work.
-
-   When type is kZoneMerge, then x and y are the identifiers of the objects to merge,
-   and the above requirement does not apply.
-*/
+// NOTE: hitZone needs to be passed absolute game coordinates to work.
+//
+// When type is kZoneMerge, then x and y are the identifiers of the objects to merge,
+// and the above requirement does not apply.
 ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
 	uint16 _di = y;
 	uint16 _si = x;
@@ -811,7 +779,6 @@
 	return ZonePtr();
 }
 
-
 ZonePtr Location::findZone(const char *name) {
 	for (ZoneList::iterator it = _zones.begin(); it != _zones.end(); ++it) {
 		if (!scumm_stricmp((*it)->_name, name)) return *it;
@@ -835,7 +802,6 @@
 	return keepZone_br(a);
 }
 
-
 template <class T>
 void Location::freeList(Common::List<T> &list, bool removeAll, Common::MemFunc1<bool, T, Location> filter) {
 	typedef typename Common::List<T>::iterator iterator;
@@ -867,8 +833,6 @@
 	}
 }
 
-
-
 Character::Character() : _ani(new Animation) {
 	_talk = NULL;
 	_head = NULL;
@@ -882,7 +846,6 @@
 	strncpy(_ani->_name, "yourself", ZONENAME_LENGTH);
 }
 
-
 void Character::setName(const char *name) {
 	_name.bind(name);
 }
@@ -903,8 +866,6 @@
 	return _name.dummy();
 }
 
-
-
 // Various ways of detecting character modes used to exist
 // inside the engine, so they have been unified in the two
 // following macros.
@@ -935,7 +896,6 @@
 	bind(name);
 }
 
-
 void CharacterName::bind(const char *name) {
 	const char *begin = name;
 	const char *end = begin + strlen(name);
@@ -1002,5 +962,4 @@
 	_engineFlags |= kEngineChangeLocation;
 }
 
-
 } // End of namespace Parallaction


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list