S3M import: why does this crash

This commit is contained in:
tildearrow 2024-06-27 23:28:43 -05:00
parent a4751663e8
commit d814aaebee

View file

@ -422,8 +422,6 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
s->loopEnd=reader.readI(); s->loopEnd=reader.readI();
defVol[i]=reader.readC(); defVol[i]=reader.readC();
logV("defVol: %d",defVol[i]);
reader.readC(); // x reader.readC(); // x
bool isPacked=reader.readC(); bool isPacked=reader.readC();
@ -455,7 +453,9 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
s->loop=flags&1; s->loop=flags&1;
s->depth=(flags&4)?DIV_SAMPLE_DEPTH_16BIT:DIV_SAMPLE_DEPTH_8BIT; s->depth=(flags&4)?DIV_SAMPLE_DEPTH_16BIT:DIV_SAMPLE_DEPTH_8BIT;
if (length>0) {
s->init(length); s->init(length);
}
if (isPacked) { if (isPacked) {
logE("ADPCM not supported!"); logE("ADPCM not supported!");
@ -584,10 +584,9 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
String name=reader.readString(28); String name=reader.readString(28);
ins->name=name; ins->name=name;
// "SCRS" // "SCRI"
reader.readI(); reader.readI();
logV("defVol: %d",defVol[i]);
logV("dsk: %d",dsk); logV("dsk: %d",dsk);
} }
@ -786,6 +785,10 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
p->data[curRow][effectCol[j]++]=0; p->data[curRow][effectCol[j]++]=0;
} }
if (effectCol[j]>=4+8*2) {
logE("oh crap!");
}
if ((effectCol[j]>>1)-2>ds.subsong[0]->pat[j].effectCols) { if ((effectCol[j]>>1)-2>ds.subsong[0]->pat[j].effectCols) {
ds.subsong[0]->pat[chanMap[j]].effectCols=(effectCol[j]>>1)-1; ds.subsong[0]->pat[chanMap[j]].effectCols=(effectCol[j]>>1)-1;
} }
@ -1045,6 +1048,9 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
} }
} }
ds.insLen=ds.ins.size();
ds.sampleLen=ds.sample.size();
if (active) quitDispatch(); if (active) quitDispatch();
BUSY_BEGIN_SOFT; BUSY_BEGIN_SOFT;
saveLock.lock(); saveLock.lock();