shithub: ft2-clone

Download patch

ref: ba70ad4ef096963531b39cfbf682d03a3e001358
parent: 09fb17bc75463e433b82710d7860655a2422844c
author: Olav Sørensen <olav.sorensen@live.no>
date: Sat Mar 14 15:11:57 EDT 2020

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.

--- a/src/ft2_module_loader.c
+++ b/src/ft2_module_loader.c
@@ -1742,7 +1742,11 @@
 
 				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;