Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't crash trying to parse a command line that's a directory (#12538)
## Summary of the Pull Request Prevents a crash that could occur when invoking `wt C:\` ## PR Checklist * [x] Closes #12535 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Detailed Description of the Pull Request / Additional comments Updates `CascadiaSettings::NormalizeCommandLine()` to check that there are a suitable number of command line arguments to be concatenated together, to prevent accessing an array index in `argv` that doesn't exist. Also prevents a test flake that could occur in `TerminalSettingsTests::CommandLineToArgvW()`, due to generating an empty command line argument. ## Validation Steps Performed Added a test, and checked that invoking each of the command lines below behaved as expected: ``` wtd C:\ # Window pops up with [error 2147942405 (0x80070005) when launching `C:\'] wtd C:\Program Files # Window pops up with [error 2147942402 (0x80070002) when launching `C:\Program Files'] wtd cmd # cmd profile pops up wtd C:\Program Files\Powershell\7\pwsh -WorkingDirectory C:\ # PowerShell profile pops up in C:\ wtd "C:\Program Files\Powershell\7\pwsh" -WorkingDirectory C:\ # PowerShell profile pops up in C:\ wtd . # Window pops up with [error 2147942405 (0x80070005) when launching `.'] ```
- Loading branch information