Fix: bounds-check drawer subtitle array access to prevent crash#557
Draft
djbclark wants to merge 1 commit into
Draft
Fix: bounds-check drawer subtitle array access to prevent crash#557djbclark wants to merge 1 commit into
djbclark wants to merge 1 commit into
Conversation
DrawerFragment.refreshSubtitle crashes with ArrayIndexOutOfBoundsException when Pref.keyKeepScreenOnWhenInForeground returns a value not in R.array.keys_keep_screen_on_when_in_foreground (e.g. after a fleet profile write). Guard with keys.indices check and show null subtitle instead of crashing.
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.
When a SharedPreference key stored for
keep_screen_on_when_in_foregrounddoes not match any entry inR.array.keys_keep_screen_on_when_in_foreground,indexOf()returns -1. The subsequent array access at that index throwsArrayIndexOutOfBoundsException, crashingDrawerFragment.onResume.This is a pre-existing bug that any code path writing an unrecognized value to the preference can trigger (not just external callers — even a fresh install picking up a default that doesn't match the keys array could hit it).
Fix: Add a bounds check (
if (i in keys.indices)) before the array access, showing no subtitle when the key isn't found. This guards the single affectedrefreshSubtitleoverride in DrawerFragment.One file changed, 7 lines added.
Thank you again for your work on AutoJs6!