From 35fd4dcf771a3b2a10bca8b3677d6b39a21e61c9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 19 Jan 2014 02:44:55 -0800 Subject: Check and trace INFO properties when reading them --- Alc/midi/sf2load.c | 12 +++++++++--- 1 file 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')) -- cgit v1.2.3