Compare commits

...

1 commit

Author SHA1 Message Date
Mike Griese 74c717acad Proposal for how to fix #11114 2021-09-29 10:34:39 -05:00
4 changed files with 37 additions and 0 deletions

View file

@ -173,6 +173,15 @@ namespace winrt::TerminalApp::implementation
}
else if (const auto& realArgs = args.ActionArgs().try_as<SplitPaneArgs>())
{
if (const auto index = newTerminalArgs.ProfileIndex())
{
if (index >= _settings->ActiveProfiles().Size())
{
args.Handled(false);
return;
}
}
_SplitPane(realArgs.SplitDirection(),
realArgs.SplitMode(),
// This is safe, we're already filtering so the value is (0, 1)
@ -290,6 +299,15 @@ namespace winrt::TerminalApp::implementation
}
else if (const auto& realArgs = args.ActionArgs().try_as<NewTabArgs>())
{
if (const auto index = newTerminalArgs.ProfileIndex())
{
if (index >= _settings->ActiveProfiles().Size())
{
args.Handled(false);
return;
}
}
LOG_IF_FAILED(_OpenNewTab(realArgs.TerminalArgs()));
args.Handled(true);
}

View file

@ -63,6 +63,12 @@ namespace winrt::TerminalApp::implementation
try
{
const auto profile{ _settings.GetProfileForArgs(newTerminalArgs) };
// GH#11114: GetProfileForArgs can return null if the index is higher
// than the number of available profiles.
if (!profile)
{
return S_FALSE;
}
const auto settings{ TerminalSettings::CreateWithNewTerminalArgs(_settings, newTerminalArgs, *_bindings) };
_CreateNewTabWithProfileAndSettings(profile, settings, existingConnection);

View file

@ -1560,6 +1560,12 @@ namespace winrt::TerminalApp::implementation
if (!profile)
{
profile = _settings.GetProfileForArgs(newTerminalArgs);
// GH#11114: GetProfileForArgs can return null if the index is
// higher than the number of available profiles.
if (!profile)
{
return;
}
controlSettings = TerminalSettings::CreateWithNewTerminalArgs(_settings, newTerminalArgs, *_bindings);
}

View file

@ -537,6 +537,13 @@ Model::Profile CascadiaSettings::GetProfileForArgs(const Model::NewTerminalArgs&
{
return profile;
}
else
{
// GH#11114 - Return NOTHING if they asked for a profile index
// outside the range of available profiles.
// Really, the caller should check this beforehand
return nullptr;
}
}
}