aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/midi/sf2load.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-01-19 02:44:55 -0800
committerChris Robinson <[email protected]>2014-01-19 02:44:55 -0800
commit35fd4dcf771a3b2a10bca8b3677d6b39a21e61c9 (patch)
tree5d416772efef3ece6346bcef3a2f8acbdc74c4bd /Alc/midi/sf2load.c
parent748be9a97d2b4489beef2e41e9776ec5e13e6f14 (diff)
Check and trace INFO properties when reading them
Diffstat (limited to 'Alc/midi/sf2load.c')
-rw-r--r--Alc/midi/sf2load.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Alc/midi/sf2load.c b/Alc/midi/sf2load.c
index 4be6a702..5bba345f 100644
--- a/Alc/midi/sf2load.c
+++ b/Alc/midi/sf2load.c
@@ -1133,6 +1133,10 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context)
list.mSize -= 4;
info.mSize -= 4;
+ if(major != 2)
+ ERROR_GOTO(error, "Unsupported SF2 format version: %d.%02d\n", major, minor);
+ TRACE("SF2 format version: %d.%02d\n", major, minor);
+
sfont.ifil = (major<<16) | minor;
}
}
@@ -1142,11 +1146,14 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context)
ERR("Invalid irom size: %d\n", info.mSize);
else
{
+ free(sfont.irom);
sfont.irom = calloc(1, info.mSize+1);
READ(stream, sfont.irom, info.mSize);
list.mSize -= info.mSize;
info.mSize -= info.mSize;
+
+ TRACE("SF2 ROM ID: %s\n", sfont.irom);
}
}
list.mSize -= info.mSize;
@@ -1155,9 +1162,8 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context)
if(READERR(stream) != 0)
ERROR_GOTO(error, "Error reading INFO chunk\n");
- if(sfont.ifil>>16 != 2)
- ERROR_GOTO(error, "Unsupported format version: %d.%02d\n", sfont.ifil>>16, sfont.ifil&0xffff);
- TRACE("Loading SF2 format version: %d.%02d\n", sfont.ifil>>16, sfont.ifil&0xffff);
+ if(sfont.ifil == 0)
+ ERROR_GOTO(error, "Missing ifil sub-chunk\n");
RiffHdr_read(&list, stream);
if(list.mCode != FOURCC('L','I','S','T'))