mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix powershell to not crash on converting recursive array to bool (#3208)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user