[Scummvm-cvs-logs] SF.net SVN: scummvm:[52795] scummvm/trunk/engines/sword2

sev at users.sourceforge.net sev at users.sourceforge.net
Sat Sep 18 14:42:23 CEST 2010


Revision: 52795
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52795&view=rev
Author:   sev
Date:     2010-09-18 12:42:23 +0000 (Sat, 18 Sep 2010)

Log Message:
-----------
SWORD2: Plug memory leaks.

Modified Paths:
--------------
    scummvm/trunk/engines/sword2/screen.cpp
    scummvm/trunk/engines/sword2/sprite.cpp

Modified: scummvm/trunk/engines/sword2/screen.cpp
===================================================================
--- scummvm/trunk/engines/sword2/screen.cpp	2010-09-18 12:08:59 UTC (rev 52794)
+++ scummvm/trunk/engines/sword2/screen.cpp	2010-09-18 12:42:23 UTC (rev 52795)
@@ -966,11 +966,15 @@
 	if (Sword2Engine::isPsx()) {
 		if (!f.open("credits.txt")) {
 			warning("Can't find credits.txt");
+
+			free(logoData);
 			return;
 		}
 	} else {
 		if (!f.open("credits.clu")) {
 			warning("Can't find credits.clu");
+
+			free(logoData);
 			return;
 		}
 	}

Modified: scummvm/trunk/engines/sword2/sprite.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sprite.cpp	2010-09-18 12:08:59 UTC (rev 52794)
+++ scummvm/trunk/engines/sword2/sprite.cpp	2010-09-18 12:42:23 UTC (rev 52795)
@@ -528,8 +528,11 @@
 				decompData = decompressHIF(s->data, tempBuf);
 
 				// Check that we correctly decompressed data
-				if (!decompData)
+				if (!decompData) {
+					free(tempBuf);
+
 					return RDERR_DECOMPRESSION;
+				}
 
 				s->w = (decompData / (s->h / 2)) * 2;
 				byte *tempBuf2 = (byte *)malloc(s->w * s->h * 10);
@@ -571,8 +574,11 @@
 					uint32 decompData = decompressHIF(s->data, tempBuf);
 
 					// Check that we correctly decompressed data
-					if (!decompData)
+					if (!decompData) {
+						free(tempBuf);
+
 						return RDERR_DECOMPRESSION;
+					}
 
 					s->w = (decompData / (s->h / 2));
 					sprite = (byte *)malloc(s->w * s->h);


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