[Scummvm-cvs-logs] SF.net SVN: scummvm:[45639] scummvm/branches/branch-1-0-0/sound

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Nov 3 21:50:24 CET 2009


Revision: 45639
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45639&view=rev
Author:   fingolfin
Date:     2009-11-03 20:50:23 +0000 (Tue, 03 Nov 2009)

Log Message:
-----------
Backport fix for bug #2890038 (FT: Crashes when entering inventory), as well as enhanced VOC decoder debug output

Modified Paths:
--------------
    scummvm/branches/branch-1-0-0/sound/audiostream.cpp
    scummvm/branches/branch-1-0-0/sound/voc.cpp

Modified: scummvm/branches/branch-1-0-0/sound/audiostream.cpp
===================================================================
--- scummvm/branches/branch-1-0-0/sound/audiostream.cpp	2009-11-03 20:49:53 UTC (rev 45638)
+++ scummvm/branches/branch-1-0-0/sound/audiostream.cpp	2009-11-03 20:50:23 UTC (rev 45639)
@@ -220,6 +220,8 @@
 		: _rate(rate), _stream(stream), _beginLoop(beginLoop), _endLoop(endLoop), _disposeAfterUse(disposeStream),
 		  _audioBlockCount(numBlocks) {
 
+		assert(numBlocks > 0);
+
 		// Allocate streaming buffer
 		if (is16Bit) {
 			_buffer = (byte *)malloc(BUFFER_SIZE * sizeof(int16));

Modified: scummvm/branches/branch-1-0-0/sound/voc.cpp
===================================================================
--- scummvm/branches/branch-1-0-0/sound/voc.cpp	2009-11-03 20:49:53 UTC (rev 45638)
+++ scummvm/branches/branch-1-0-0/sound/voc.cpp	2009-11-03 20:50:23 UTC (rev 45639)
@@ -52,6 +52,8 @@
 static byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate, int &loops, int &begin_loop, int &end_loop) {
 	VocFileHeader fileHeader;
 
+	debug(2, "loadVOCFromStream");
+
 	if (stream.read(&fileHeader, 8) != 8)
 		goto invalid;
 
@@ -92,6 +94,8 @@
 		len |= stream.readByte() << 8;
 		len |= stream.readByte() << 16;
 
+		debug(2, "Block code %d, len %d", code, len);
+
 		switch (code) {
 		case 1:
 		case 9: {
@@ -153,7 +157,7 @@
 			stream.readByte();
 			break;
 		default:
-			warning("Unhandled code in VOC file : %d", code);
+			warning("Unhandled code %d in VOC file (len %d)", code, len);
 			return ret_sound;
 		}
 	}
@@ -174,6 +178,8 @@
 	int currentBlock = 0;
 	int size = 0;
 
+	debug(2, "parseVOCFormat");
+
 	if (stream.read(&fileHeader, 8) != 8)
 		goto invalid;
 
@@ -213,6 +219,8 @@
 		len |= stream.readByte() << 8;
 		len |= stream.readByte() << 16;
 
+		debug(2, "Block code %d, len %d", code, len);
+
 		switch (code) {
 		case 1:
 		case 9: {
@@ -276,7 +284,7 @@
 			stream.readByte();
 			break;
 		default:
-			warning("Unhandled code in VOC file : %d", code);
+			warning("Unhandled code %d in VOC file (len %d)", code, len);
 			return 0;
 		}
 	}
@@ -292,8 +300,13 @@
 
 	int numBlocks = parseVOCFormat(stream, block, rate, loops, begin_loop, end_loop);
 
-	AudioStream* audioStream = makeLinearDiskStream(stream, block, numBlocks, rate, flags, takeOwnership, begin_loop, end_loop);
+	AudioStream *audioStream = 0;
 
+	// Create an audiostream from the data. Note the numBlocks may be 0,
+	// e.g. when invalid data is encountered. See bug #2890038.
+	if (numBlocks)
+		audioStream = makeLinearDiskStream(stream, block, numBlocks, rate, flags, takeOwnership, begin_loop, end_loop);
+
 	delete[] block;
 
 	return audioStream;


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