diff --git a/Frameworks/playptmod/playptmod/playptmod.c b/Frameworks/playptmod/playptmod/playptmod.c index 8eca66850..e17c5248a 100644 --- a/Frameworks/playptmod/playptmod/playptmod.c +++ b/Frameworks/playptmod/playptmod/playptmod.c @@ -1333,12 +1333,13 @@ int playptmod_LoadMem(void *_p, const unsigned char *buf, unsigned long bufLengt s->offset = sampleOffset; j = (s->length + 1) / 2 + 5 + 16; + if ( j > s->length ) j = s->length; bufread(tempSample, 1, j, fmodule); smpDat8 = tempSample; - if (s->length > 5 && memcmp(smpDat8, "ADPCM", 5) == 0) + if (j > 5 + 16 && memcmp(smpDat8, "ADPCM", 5) == 0) { s->reallength = j; }