ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

commit ba70ad4ef096963531b39cfbf682d03a3e001358
parent 09fb17bc75463e433b82710d7860655a2422844c
Author: Olav Sørensen <olav.sorensen@live.no>
Date:   Sat, 14 Mar 2020 19:11:30 +0100

Crash-fix when loading very specific S3M modules

If an S3M has an Oxx (Set Sample Offset) effect next to a sample number who points to an empty sample, the program would crash during loading.

Diffstat:
Msrc/ft2_module_loader.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/ft2_module_loader.c b/src/ft2_module_loader.c @@ -1742,7 +1742,11 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) if (pattTon->effTyp == 0x9 && pattTon->eff > 0 && pattTon->instr > 0 && pattTon->instr <= ai && ai <= 128) { - s = &instrTmp[pattTon->instr]->samp[0]; + instrTyp *ins = instrTmp[pattTon->instr]; + if (ins == NULL) + continue; // empty instrument (sample) + + s = &ins->samp[0]; if (s->len > 0 && (s->typ & 1)) // only handle non-empty looping samples { uint32_t loopEnd = s->repS + s->repL;