summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-02-01 14:29:47 -0800
committerChris Robinson <[email protected]>2014-02-01 14:29:47 -0800
commit68a32a34869c6032834b11a943108b0ce2705f6b (patch)
tree4ac6ef0c00679f5824070c909755100142831e5d /Alc
parenta4bc0a46e9e0fe001d4c14909b47ed4ac8d81960 (diff)
Fix an infinite loop when loading SF2 samples on big endian machines
Diffstat (limited to 'Alc')
-rw-r--r--Alc/midi/sf2load.c7
1 files 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;