Repository navigation
Guard generic parameter stack back() access - #1639
Merged
Ryan Shepherd (DefaultRyan) merged 1 commit intoOct 22, 2026
Merged
Ryan Shepherd (DefaultRyan) merged 1 commit into
Ryan Shepherd (DefaultRyan) merged 1 commit into
Conversation
- add explicit checks before using generic_param_stack.back() when rendering GenericTypeIndex - throw detailed invalid_argument messages for missing generic context and out-of-range generic parameter indexes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 61a69fb9-fb73-4bf5-b557-d60d7f503390
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Both invalid-access cases are guarded without changing valid-path behavior, and no unresolved issues were identified.
No open issues 🎉
What changed in this PR
This PR hardens generic type parameter handling in the cppwinrt generator so malformed metadata produces explicit errors instead of invalid container access.
Changes:
- Checks for an empty generic parameter stack before calling
.back(). - Validates the parameter index before indexing, with diagnostics for both failure cases.
- Preserves behavior for valid generic parameter references.
| File | Description |
|---|---|
cppwinrt/type_writers.h |
Guards generic parameter lookup and reports missing context or out-of-range indices. |
Review effort: Balanced
Manodasan Wignarajah (manodasanW)
approved these changes
Oct 21, 2026
Vineeth Thomas Alex (vineeththomasalex)
approved these changes
Oct 22, 2026
Scott Jones (Scottj1s)
approved these changes
Oct 22, 2026
Ryan Shepherd (DefaultRyan)
deleted the
user/defaultryan/guard-generic-param-stack-back
branch
October 22, 2026 17:34
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.
Summary
generic_param_stack.back()[var.index]incppwinrt/type_writers.hinvalid_argumentdiagnostics when generic parameter context is missing or the index is out of rangeBehavior change
For malformed metadata that previously reached an unguarded
.back()path, cppwinrt now fails deterministically with actionable error text.Files updated
cppwinrt/type_writers.hValidation
cppwinrttarget fromcppwinrt.sln(Debug|x64,v143)