Skip to content

Commit a6d40ba

Browse files
huiren-jiangheaths
authored andcommitted
Fix crash when format specifiers are passed
1 parent 74d63d7 commit a6d40ba

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

docker/Tests/vswhere.tests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ Describe 'vswhere' {
200200
@($instances.instances.instance).Count | Should Be 1
201201
@($instances.instances.instance)[0].instanceId | Should Be 2
202202
}
203+
204+
It 'does not crash when passed %0' {
205+
$message = C:\bin\vswhere.exe -version '%0'
206+
$message[-1] | Should Be 'Error 0x57: The version "%0" is not a valid version range'
207+
}
203208
}
204209

205210
Context '-latest' {

inc/Common.Debug.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88
<ItemDefinitionGroup>
99
<ClCompile>
10+
<LanguageStandard>stdcpp14</LanguageStandard>
1011
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
1112
</ClCompile>
1213
<Lib>

inc/Common.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88
<ItemDefinitionGroup>
99
<ClCompile>
10+
<LanguageStandard>stdcpp14</LanguageStandard>
1011
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
1112
</ClCompile>
1213
<Lib>

src/vswhere/Program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int wmain(_In_ int argc, _In_ LPCWSTR argv[])
9292
const auto* err = dynamic_cast<const win32_error*>(&ex);
9393
if (err)
9494
{
95-
console.WriteLine(err->wwhat());
95+
console.WriteLine(L"%ls", err->wwhat());
9696
}
9797
else
9898
{

0 commit comments

Comments
 (0)