fix memory corruption when deleting unused samples
This commit is contained in:
parent
08764e0e88
commit
aa7ab87b21
|
@ -939,6 +939,7 @@ void DivEngine::delUnusedSamples() {
|
||||||
|
|
||||||
bool* isUsed=new bool[song.sample.size()];
|
bool* isUsed=new bool[song.sample.size()];
|
||||||
memset(isUsed,0,song.sample.size()*sizeof(bool));
|
memset(isUsed,0,song.sample.size()*sizeof(bool));
|
||||||
|
int isUsedMax=((int)song.sample.size())-1;
|
||||||
|
|
||||||
// scan in instruments
|
// scan in instruments
|
||||||
for (DivInstrument* i: song.ins) {
|
for (DivInstrument* i: song.ins) {
|
||||||
|
@ -1020,10 +1021,10 @@ void DivEngine::delUnusedSamples() {
|
||||||
if (!isUsed[i]) {
|
if (!isUsed[i]) {
|
||||||
delSampleUnsafe(i,false);
|
delSampleUnsafe(i,false);
|
||||||
// rotate
|
// rotate
|
||||||
for (int j=i; j<255; j++) {
|
for (int j=i; j<isUsedMax; j++) {
|
||||||
isUsed[j]=isUsed[j+1];
|
isUsed[j]=isUsed[j+1];
|
||||||
}
|
}
|
||||||
isUsed[255]=true;
|
isUsed[isUsedMax]=true;
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue