Skip to content

Commit

Permalink
GUI: fix possible crash in find/replace
Browse files Browse the repository at this point in the history
issue #2328
  • Loading branch information
tildearrow committed Jan 17, 2025
1 parent 6414de2 commit cfcad1e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/gui/findReplace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void FurnaceGUI::doReplace() {

switch (queryReplaceEffectPos) {
case 0: // clear
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols; j++) {
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols && j<8; j++) {
effectOrder[j]=j;
}
break;
Expand All @@ -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; j<e->song.subsong[i.subsong]->pat[i.x].effectCols; j++) {
for (int j=0; j<e->song.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;
}
Expand All @@ -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; j<e->song.subsong[i.subsong]->pat[i.x].effectCols; j++) {
for (int j=0; j<e->song.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;
}
Expand All @@ -406,7 +406,7 @@ void FurnaceGUI::doReplace() {
}
case 3: { // insert in free spaces
int placementIndex=0;
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols; j++) {
for (int j=0; j<e->song.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;
}
Expand All @@ -415,7 +415,7 @@ void FurnaceGUI::doReplace() {
}
}

for (int j=0; j<queryReplaceEffectCount; j++) {
for (int j=0; j<queryReplaceEffectCount && j<8; j++) {
signed char pos=effectOrder[j];
if (pos==-1) continue;
if (queryReplaceEffectDo[j]) {
Expand Down

0 comments on commit cfcad1e

Please sign in to comment.