[Scummvm-cvs-logs] SF.net SVN: scummvm:[48321] scummvm/trunk/engines/teenagent

megath at users.sourceforge.net megath at users.sourceforge.net
Sat Mar 20 16:24:17 CET 2010


Revision: 48321
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48321&view=rev
Author:   megath
Date:     2010-03-20 15:24:16 +0000 (Sat, 20 Mar 2010)

Log Message:
-----------
fixed stream leaks

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/font.cpp
    scummvm/trunk/engines/teenagent/inventory.cpp
    scummvm/trunk/engines/teenagent/music.cpp
    scummvm/trunk/engines/teenagent/resources.h
    scummvm/trunk/engines/teenagent/scene.cpp
    scummvm/trunk/engines/teenagent/teenagent.cpp

Modified: scummvm/trunk/engines/teenagent/font.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/font.cpp	2010-03-20 15:00:42 UTC (rev 48320)
+++ scummvm/trunk/engines/teenagent/font.cpp	2010-03-20 15:24:16 UTC (rev 48321)
@@ -42,6 +42,7 @@
 	data = new byte[s->size()];
 	s->read(data, s->size());
 	debug(0, "font size: %d", s->size());
+	delete s;
 }
 
 uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color) {

Modified: scummvm/trunk/engines/teenagent/inventory.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/inventory.cpp	2010-03-20 15:00:42 UTC (rev 48320)
+++ scummvm/trunk/engines/teenagent/inventory.cpp	2010-03-20 15:24:16 UTC (rev 48321)
@@ -39,10 +39,13 @@
 	FilePack varia;
 	varia.open("varia.res");
 
-	Common::SeekableReadStream *s = varia.getStream(3);
-	assert(s != NULL);
-	debug(0, "loading inventory background...");
-	background.load(s, Surface::kTypeOns);
+	{
+		Common::SeekableReadStream *s = varia.getStream(3);
+		assert(s != NULL);
+		debug(0, "loading inventory background...");
+		background.load(s, Surface::kTypeOns);
+		delete s;
+	}
 
 	uint32 items_size = varia.getSize(4);
 	if (items_size == 0)

Modified: scummvm/trunk/engines/teenagent/music.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/music.cpp	2010-03-20 15:00:42 UTC (rev 48320)
+++ scummvm/trunk/engines/teenagent/music.cpp	2010-03-20 15:24:16 UTC (rev 48321)
@@ -63,16 +63,14 @@
 		byte sampleResource = ((sample >> 4) & 0x0F) * 10 + (sample & 0x0F);
 		debug(0, "currSample = %d, sample = 0x%02x, resource: %d", currSample, sample, sampleResource);
 		uint32 sampleSize = res->sam_mmm.getSize(sampleResource);
-		Common::SeekableReadStream *in = res->sam_mmm.getStream(sampleResource);
-
-		if (in == 0) {
+		if (sampleSize == 0) {
 			warning("load: invalid sample %d (0x%02x)", sample, sample);
 			_samples[sample].clear();
 			continue;
 		}
 
 		_samples[sample].resize(sampleSize);
-		in->read(_samples[sample].data, sampleSize);
+		res->sam_mmm.read(sampleResource, _samples[sample].data, sampleSize);
 	}
 
 	// Load the music data
@@ -101,6 +99,7 @@
 			debug(0, "unhandled music command %02x", cmd);
 		}
 	}
+	delete stream;
 	_currRow = 0;
 	_id = id;
 	return true;

Modified: scummvm/trunk/engines/teenagent/resources.h
===================================================================
--- scummvm/trunk/engines/teenagent/resources.h	2010-03-20 15:00:42 UTC (rev 48320)
+++ scummvm/trunk/engines/teenagent/resources.h	2010-03-20 15:24:16 UTC (rev 48321)
@@ -48,12 +48,11 @@
 	//void loadOns(Graphics::Surface &surface, int id, uint16 &dst);
 
 #ifdef __PSP__
-	TransientFilePack off, on, ons, lan000, lan500, sam_mmm, sam_sam;
+	TransientFilePack off, on, ons, lan000, lan500, sam_mmm, sam_sam, mmm;
 #else
-	FilePack off, on, ons, lan000, lan500, sam_mmm, sam_sam;
+	FilePack off, on, ons, lan000, lan500, sam_mmm, sam_sam, mmm;
 #endif
 
-	MemoryPack mmm;
 	Segment cseg, dseg, eseg;
 	Font font7, font8;
 };

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2010-03-20 15:00:42 UTC (rev 48320)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2010-03-20 15:24:16 UTC (rev 48321)
@@ -218,6 +218,7 @@
 	if (teenagent.empty())
 		error("invalid mark animation");
 
+	delete s;
 	s = varia.getStream(2);
 	if (s == NULL)
 		error("invalid resource data");
@@ -226,6 +227,7 @@
 	if (teenagent_idle.empty())
 		error("invalid mark animation");
 
+	delete s;
 	varia.close();
 	loadObjectData();
 }
@@ -335,8 +337,10 @@
 		ons = new Surface[ons_count];
 		for (uint32 i = 0; i < ons_count; ++i) {
 			Common::SeekableReadStream *s = res->ons.getStream(on_id[i]);
-			if (s != NULL)
+			if (s != NULL) {
 				ons[i].load(s, Surface::kTypeOns);
+				delete s;
+			}
 		}
 	}
 }
@@ -437,6 +441,7 @@
 	custom_animation[idx].loop = loop;
 	custom_animation[idx].paused = paused;
 	custom_animation[idx].ignore = ignore;
+	delete s;
 }
 
 void Scene::playActorAnimation(uint id, bool loop, bool ignore) {
@@ -448,6 +453,7 @@
 	actor_animation.load(s);
 	actor_animation.loop = loop;
 	actor_animation.ignore = ignore;
+	delete s;
 }
 
 Animation * Scene::getAnimation(byte slot) {

Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp	2010-03-20 15:00:42 UTC (rev 48320)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp	2010-03-20 15:24:16 UTC (rev 48321)
@@ -333,13 +333,13 @@
 	memset(palette, 0, sizeof(palette));
 	{
 		Common::SeekableReadStream *s = varia.getStream(5);
-		for(uint c = 0; c < 0x100; ++c) {
-			uint idx = c * 4;
-			s->read(palette + idx, 3);
-			palette[idx] *= 4;
-			palette[idx + 1] *= 4;
-			palette[idx + 2] *= 4;
+		for(uint c = 0; c < 0x400; c += 4) {
+			s->read(palette + c, 3);
+			palette[c] *= 4;
+			palette[c + 1] *= 4;
+			palette[c + 2] *= 4;
 		}
+		delete s;
 	}
 
 	_system->setPalette(palette, 0, 0x100);
@@ -919,7 +919,7 @@
 	//debug(0, "playing %u samples...", size);
 
 	Audio::AudioStream *stream = Audio::makeRawStream(data, size, 11025, 0);
-	_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream);
+	_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream); //dispose is YES by default
 }
 
 


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