Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't explode if we try to parse an empty keys #16003

Merged
merged 3 commits into from
Sep 20, 2023

Conversation

zadjii-msft
Copy link
Member

Saving the SUI with an empty "keys" will persist "keys": "" to the JSON.

The keychord parser tries to parse that. KeyChordSerialization.cpp@_fromString returns a KeyChord with both vkey and scancode set to 0, and the ctor asserts and explodes.

We shouldn't do that.

Closes #13221

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-SettingsUI Anything specific to the SUI Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news. labels Sep 19, 2023
@@ -348,7 +348,7 @@ KeyChord ConversionTrait<KeyChord>::FromJson(const Json::Value& json)
{
throw winrt::hresult_invalid_argument{};
}
return _fromString(til::u8u16(keyChordText));
return keyChordText.empty() ? nullptr : _fromString(til::u8u16(keyChordText));
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to move this check into _fromString so that the above KeyChordSerialization::FromString method also doesn't explode.

@DHowett DHowett merged commit d272fc4 into main Sep 20, 2023
17 checks passed
@DHowett DHowett deleted the dev/migrie/b/13221-easy-enough branch September 20, 2023 16:46
DHowett pushed a commit that referenced this pull request Sep 22, 2023
Saving the SUI with an empty "keys" will persist `"keys": ""` to the
JSON.

The keychord parser tries to parse that.
`KeyChordSerialization.cpp@_fromString` returns a KeyChord with both
vkey and scancode set to 0, and the ctor asserts and explodes.

We shouldn't do that.

Closes #13221

(cherry picked from commit d272fc4)
Service-Card-Id: 90597699
Service-Version: 1.18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-SettingsUI Anything specific to the SUI Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news.
Projects
Development

Successfully merging this pull request may close these issues.

[Settings UI] Adding an action with no key chord hits an assert
3 participants