Defend against a crash in dynamically-created menus#16
Open
ceejbot wants to merge 1 commit intoExit-9B:mainfrom
Open
Defend against a crash in dynamically-created menus#16ceejbot wants to merge 1 commit intoExit-9B:mainfrom
ceejbot wants to merge 1 commit intoExit-9B:mainfrom
Conversation
If both the values and the short names arrays are empty, `GetValue()` returns empty string, which `std::ranges::find()` does not find. The distance from array end to beginning is therefore 0, and the subsequent index into the empty `shortNames` causes a crash. Detect this case and return empty string. I tripped over this because I have some dynamic menus that are sometimes empty. I've worked around the problem in my mod, but I thought you might want the fix.
ceejbot
added a commit
to ceejbot/soulsy
that referenced
this pull request
Oct 3, 2023
I believe I have proven it to my satisfaction. If it is not a fix, I will do something drastic like eat an entire pint of ice cream in one sitting. There is no ice cream in my house, so this would obviously be traumatic. The root bug is in how MCM-Helper handles empty dynamic menus, and it's been around for a while. The workaround is to never give MCM-Helper an empty array, but instead to show the string "-- empty --" (or its translation) in the drop-down. This is a PR with a fix for MCM-Helper: Exit-9B/MCM-Helper#16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This bug showed up as a crash in
MenuControl::GetShortText()in my mod.If both the values and the short names arrays are empty,
GetValue()returns empty string, whichstd::ranges::find()does not find in the empty short names array. The distance from array end to beginning is therefore 0, and the subsequent index intoshortNamescauses a crash.Detect this case and return empty string.
I tripped over this because I have some dynamic menus that are sometimes empty. I've worked around the problem in my mod, but I thought you might want the fix.