Fix issue 14831: TaskDialogPage.GetBoundButtonByID throws IndexOutOfRangeException when TaskDialogIndirect returns unexpected button ID - #14842
Open
SimonZhao888 wants to merge 1 commit into
Conversation
…angeException when TaskDialogIndirect returns unexpected button ID
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.
Fixes #14831
Root Cause
TaskDialogPage.GetBoundButtonByIDandGetBoundRadioButtonByIDmap the ID returned by the native API directly to an array index without performing bounds checking.If
TaskDialogIndirectreturns an ID outside the current page configuration during an abnormal closure (e.g., an ID in the "custom" range when no custom buttons are defined), anIndexOutOfRangeExceptionis triggered, preventing the intended fallback logic from executing.Proposed changes
custom-buttonindex inGetBoundButtonByID; returnnullif the index is out of bounds.radio-buttonindex inGetBoundRadioButtonByID; returnnullif the index is out of bounds.nullreturn value in theTaskDialogTDN_RADIO_BUTTON_CLICKEDcallback to prevent potential dereferencing issues.nullinstead of throwing an exception.Customer Impact
Regression?
Risk
Screenshots
Before
2026-08-04.142359.mp4
After
2026-08-04.142529.mp4
Test methodology
Test environment(s)
Test Project
TaskDialogIssue14831.zip
Microsoft Reviewers: Open in CodeFlow