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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon Sep 14 21:32:36 CEST 2009


Revision: 44087
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44087&view=rev
Author:   lordhoto
Date:     2009-09-14 19:32:35 +0000 (Mon, 14 Sep 2009)

Log Message:
-----------
Backport of revisions 44084, 44085, 44086.

Modified Paths:
--------------
    scummvm/branches/branch-1-0-0/engines/groovie/music.cpp
    scummvm/branches/branch-1-0-0/sound/softsynth/adlib.cpp

Modified: scummvm/branches/branch-1-0-0/engines/groovie/music.cpp
===================================================================
--- scummvm/branches/branch-1-0-0/engines/groovie/music.cpp	2009-09-14 19:30:46 UTC (rev 44086)
+++ scummvm/branches/branch-1-0-0/engines/groovie/music.cpp	2009-09-14 19:32:35 UTC (rev 44087)
@@ -557,7 +557,14 @@
 	}
 
 	// Prepare the AdLib Instrument array from the GTL entry
-	byte data[13];
+	//
+	// struct AdlibInstrument used by our AdLib MIDI synth is 30 bytes.
+	// Since we pass data + 2 for non percussion instruments we need to
+	// have a buffer of size 32, so there are no invalid memory reads,
+	// when setting up an AdLib instrument.
+	byte data[32];
+	memset(data, 0, sizeof(data));
+
 	data[2] = timbre.data[1];        // mod_characteristic
 	data[3] = timbre.data[2] ^ 0x3F; // mod_scalingOutputLevel
 	data[4] = ~timbre.data[3];       // mod_attackDecay

Modified: scummvm/branches/branch-1-0-0/sound/softsynth/adlib.cpp
===================================================================
--- scummvm/branches/branch-1-0-0/sound/softsynth/adlib.cpp	2009-09-14 19:30:46 UTC (rev 44086)
+++ scummvm/branches/branch-1-0-0/sound/softsynth/adlib.cpp	2009-09-14 19:32:35 UTC (rev 44087)
@@ -35,9 +35,18 @@
 class MidiDriver_ADLIB;
 struct AdlibVoice;
 
+// We use packing for the following two structs, because the code
+// does simply copy them over from byte streams, without any
+// serialization. Check AdlibPart::sysEx_customInstrument for an
+// example of this.
+//
+// It might be very well possible, that none of the compilers we support
+// add any padding bytes at all, since the structs contain only variables
+// of the type 'byte'. But better safe than sorry.
+#include "common/pack-start.h"
 struct InstrumentExtra {
 	byte a, b, c, d, e, f, g, h;
-};
+} PACKED_STRUCT;
 
 struct AdlibInstrument {
 	byte mod_characteristic;
@@ -58,7 +67,8 @@
 	byte duration;
 
 	AdlibInstrument() { memset(this, 0, sizeof(AdlibInstrument)); }
-};
+} PACKED_STRUCT;
+#include "common/pack-end.h"
 
 class AdlibPart : public MidiChannel {
 	friend class MidiDriver_ADLIB;


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