10000 Fix powershell to not crash on converting recursive array to bool by PetSerAl · Pull Request #3208 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
10000 Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ internal static bool IsTrue(IList objectArray)
// 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)
{
Expand Down
5 changes: 5 additions & 0 deletions test/powershell/engine/Api/LanguagePrimitive.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
0