Fix powershell to not crash on converting recursive array to bool (#3208)
This commit is contained in:
parent
e3b59e0f51
commit
ae37a9fafe
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user