diff --git a/src/gui/findReplace.cpp b/src/gui/findReplace.cpp index 7a7492317..157de0441 100644 --- a/src/gui/findReplace.cpp +++ b/src/gui/findReplace.cpp @@ -371,7 +371,7 @@ void FurnaceGUI::doReplace() { switch (queryReplaceEffectPos) { case 0: // clear - for (int j=0; jsong.subsong[i.subsong]->pat[i.x].effectCols; j++) { + for (int j=0; jsong.subsong[i.subsong]->pat[i.x].effectCols && j<8; j++) { effectOrder[j]=j; } break; @@ -380,7 +380,7 @@ void FurnaceGUI::doReplace() { for (int j=0; j<8 && placementIndex<8 && i.effectPos[j]>=0; j++) { effectOrder[placementIndex++]=i.effectPos[j]; } - for (int j=0; jsong.subsong[i.subsong]->pat[i.x].effectCols; j++) { + for (int j=0; jsong.subsong[i.subsong]->pat[i.x].effectCols && placementIndex<8 && j<8; j++) { if (p->data[i.y][4+j*2]!=-1 || p->data[i.y][5+j*2]!=-1) { effectOrder[placementIndex++]=j; } @@ -392,7 +392,7 @@ void FurnaceGUI::doReplace() { for (int j=0; j<8 && placementIndex<8 && i.effectPos[j]>=0; j++) { effectOrder[placementIndex++]=i.effectPos[j]; } - for (int j=0; jsong.subsong[i.subsong]->pat[i.x].effectCols; j++) { + for (int j=0; jsong.subsong[i.subsong]->pat[i.x].effectCols && placementIndex<8 && j<8; j++) { if (p->data[i.y][4+j*2]!=-1 || p->data[i.y][5+j*2]!=-1) { effectOrder[placementIndex++]=j; } @@ -406,7 +406,7 @@ void FurnaceGUI::doReplace() { } case 3: { // insert in free spaces int placementIndex=0; - for (int j=0; jsong.subsong[i.subsong]->pat[i.x].effectCols; j++) { + for (int j=0; jsong.subsong[i.subsong]->pat[i.x].effectCols && j<8; j++) { if (p->data[i.y][4+j*2]==-1 && p->data[i.y][5+j*2]==-1) { effectOrder[placementIndex++]=j; } @@ -415,7 +415,7 @@ void FurnaceGUI::doReplace() { } } - for (int j=0; j