Skip to content

Commit

Permalink
Cut it down the middle
Browse files Browse the repository at this point in the history
  • Loading branch information
krazynez committed Dec 22, 2024
1 parent c96e29f commit 65a6236
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions extras/menus/arkMenu/src/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1571,22 +1571,20 @@ void Browser::optionsMenu(){
else if (pad->right()) {
common::playMenuSound();
do {
if (pEntryIndex+3 < MAX_OPTIONS-1) {
pEntryIndex += 3;
}
else {
if(pEntryIndex >= (int)((MAX_OPTIONS-1)/2))
pEntryIndex = MAX_OPTIONS-1;
}
else if(pEntryIndex <= 0)
pEntryIndex = (int)((MAX_OPTIONS-1)/2);
} while (pEntries[pEntryIndex] == NULL);
}
// Left
else if (pad->left()) {
common::playMenuSound();
do {
if (pEntryIndex-3 < 0)
if(pEntryIndex <= (int)((MAX_OPTIONS-1)/2))
pEntryIndex = 0;
else
pEntryIndex -= 3;
else if(pEntryIndex <= MAX_OPTIONS-1)
pEntryIndex = (int)((MAX_OPTIONS-1)/2);
} while (pEntries[pEntryIndex] == NULL);
}
else if (pad->decline() || pad->LT()){
Expand Down

2 comments on commit 65a6236

@aldostools
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new code could cause and infinite loop; if pEntries[pEntryIndex] == NULL, the variable pEntryIndex could not change and the loop will continue repeating.

If pEntries[pEntryIndex] != NULL, the loop will exit fine.

@krazynez
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that actually causing it to crash doing it like that, I thought that initially also. 😂

Please sign in to comment.