From 68a32a34869c6032834b11a943108b0ce2705f6b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 1 Feb 2014 14:29:47 -0800 Subject: Fix an infinite loop when loading SF2 samples on big endian machines --- Alc/midi/sf2load.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Alc/midi/sf2load.c b/Alc/midi/sf2load.c index 5bba345f..73b5d9d4 100644 --- a/Alc/midi/sf2load.c +++ b/Alc/midi/sf2load.c @@ -1192,15 +1192,18 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context) READ(stream, ptr, smpl.mSize); else { - while(smpl.mSize > 0) + ALuint total = 0; + while(total < smpl.mSize) { ALbyte buf[4096]; - ALuint todo = minu(smpl.mSize, sizeof(buf)); + ALuint todo = minu(smpl.mSize-total, sizeof(buf)); ALuint i; READ(stream, buf, todo); for(i = 0;i < todo;i++) ptr[i] = buf[i^1]; + + total += todo; } } list.mSize -= smpl.mSize; -- cgit v1.2.3