aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamieson Christian2003-05-20 16:50:16 +0000
committerJamieson Christian2003-05-20 16:50:16 +0000
commite2e23affcf73f8f8186090f0db06fafb29d8fc69 (patch)
tree3a05e940a4cdcce273774c7a9937b0c30f3faa47
parenta768deb83fe38ce879e46339431a8a49d9cf8c73 (diff)
downloadscummvm-rg350-e2e23affcf73f8f8186090f0db06fafb29d8fc69.tar.gz
scummvm-rg350-e2e23affcf73f8f8186090f0db06fafb29d8fc69.tar.bz2
scummvm-rg350-e2e23affcf73f8f8186090f0db06fafb29d8fc69.zip
Fixed memory overrun problem
svn-id: r7745
-rw-r--r--simon/midi.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/simon/midi.cpp b/simon/midi.cpp
index 6f7c2bdbb2..eb91231e92 100644
--- a/simon/midi.cpp
+++ b/simon/midi.cpp
@@ -228,7 +228,10 @@ static int simon1_gmf_size[] = {
void MidiPlayer::playSMF (File *in, int song) {
_system->lock_mutex (_mutex);
clearConstructs();
- uint32 size = in->size() - in->pos();
+
+ // When computing the resource size, add
+ // 4 for our own End of Track on GMF resources.
+ uint32 size = in->size() - in->pos() + 4;
if (size > 64000)
size = 64000;
_data = (byte *) calloc (size, 1);
@@ -237,7 +240,7 @@ void MidiPlayer::playSMF (File *in, int song) {
// For GMF files, we're going to have to use
// hardcoded size tables.
if (!memcmp (_data, "GMF\x1", 4) && size == 64000)
- size = simon1_gmf_size [song];
+ size = simon1_gmf_size [song] + 4; // Again, +4 for End of Track
MidiParser *parser = MidiParser::createParser_SMF();
parser->property (MidiParser::mpMalformedPitchBends, 1);