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

@ -421,8 +421,6 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
s->loopStart=reader.readI();
s->loopEnd=reader.readI();
defVol[i]=reader.readC();
logV("defVol: %d",defVol[i]);
reader.readC(); // x
@ -455,7 +453,9 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
s->loop=flags&1;
s->depth=(flags&4)?DIV_SAMPLE_DEPTH_16BIT:DIV_SAMPLE_DEPTH_8BIT;
s->init(length);
if (length>0) {
s->init(length);
}
if (isPacked) {
logE("ADPCM not supported!");
@ -584,10 +584,9 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
String name=reader.readString(28);
ins->name=name;
// "SCRS"
// "SCRI"
reader.readI();
logV("defVol: %d",defVol[i]);
logV("dsk: %d",dsk);
}
@ -786,6 +785,10 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
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) {
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();
BUSY_BEGIN_SOFT;
saveLock.lock();