Fix powershell to not crash on converting recursive array to bool (#3208)

This commit is contained in:
PetSerAl 2017-02-27 21:54:07 +03:00 committed by Dongbo Wang
parent e3b59e0f51
commit ae37a9fafe
2 changed files with 6 additions and 1 deletions

View File

@ -935,7 +935,7 @@ namespace System.Management.Automation
// but since we don't want this to recurse indefinitely
// we explicitly check the case where it would recurse
// and deal with it.
IList firstElement = objectArray[0] as IList;
IList firstElement = PSObject.Base(objectArray[0]) as IList;
if (firstElement == null)
{

View File

@ -25,4 +25,9 @@
$ObjArray = [System.Management.Automation.LanguagePrimitives]::ConvertTo($col, [object[]])
$ObjArray.Length | Should Be $col.Count
}
It "Casting recursive array to bool should not cause crash" {
$a[0] = $a = [PSObject](,1)
[System.Management.Automation.LanguagePrimitives]::IsTrue($a) | Should Be $true
}
}