X Tutup
Skip to content

Fix null reference exception in ForEach-Object -Parallel input processing#10577

Merged
daxian-dbw merged 1 commit intoPowerShell:masterfrom
PaulHigin:fix-foreach-parallel-bug1
Sep 20, 2019
Merged

Fix null reference exception in ForEach-Object -Parallel input processing#10577
daxian-dbw merged 1 commit intoPowerShell:masterfrom
PaulHigin:fix-foreach-parallel-bug1

Conversation

@PaulHigin
Copy link
Contributor

PR Summary

Fixes a null reference exception in the ForEach-Object -Parallel experimental feature.

PR Context

Piped input can be null, but a type check in parallel processing was not accounting for it. The result was a null reference exception.

Fix is to add a null check.

PR Checklist

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 20, 2019
@iSazonov iSazonov added this to the 7.0.0-preview.5 milestone Sep 20, 2019
// Validate piped InputObject
if (_inputObject.BaseObject is ScriptBlock)
if (_inputObject != null &&
_inputObject.BaseObject is ScriptBlock)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message for null does not look correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A null input object is valid, so there is no error for that. This check just prevents a null dereference when checking the input type.

@daxian-dbw daxian-dbw added the AutoMerge informs the bot to automerge the PR label Sep 20, 2019
@ghost
Copy link

ghost commented Sep 20, 2019

Hello @daxian-dbw!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 24 hours, a condition that will be fulfilled in about 30 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@daxian-dbw daxian-dbw merged commit ecad5f1 into PowerShell:master Sep 20, 2019
@PaulHigin PaulHigin deleted the fix-foreach-parallel-bug1 branch September 20, 2019 19:04
@ghost
Copy link

ghost commented Oct 23, 2019

🎉v7.0.0-preview.5 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AutoMerge informs the bot to automerge the PR CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup