Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix static analysis issues: null checks, concurrency, and logic errors#26588

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
aaron-seq wants to merge3 commits intoPowerShell:master
base:master
Choose a base branch
Loading
fromaaron-seq:fix/static-analysis-issues
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Fix static analysis issues: null checks, concurrency, and logic errors
  • Loading branch information
@aaron-seq
aaron-seq committedDec 8, 2025
commit454f51dbd98e240685dfd6464e97d1d6acf5130a
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,10 +165,13 @@ protected void GetCimInstanceInternal(CimBaseCommand cmdlet)
case CimBaseCommand.CimInstanceSessionSet:
{
CimInstance instance = GetCimInstanceParameter(cmdlet);
nameSpace = ConstValue.GetNamespace(instance.CimSystemProperties.Namespace);
foreach (CimSessionProxy proxy in proxys)
if (instance != null)
{
proxy.GetInstanceAsync(nameSpace, instance);
nameSpace = ConstValue.GetNamespace(instance.CimSystemProperties.Namespace);
foreach (CimSessionProxy proxy in proxys)
{
proxy.GetInstanceAsync(nameSpace, instance);
}
}
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -143,7 +143,7 @@ internal static class DebugHelper
/// <summary>
/// Whether the log been initialized.
/// </summary>
private static bool logInitialized = false;
private staticvolatilebool logInitialized = false;

internal static bool GenerateVerboseMessage { get; set; } = true;

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -278,7 +278,7 @@ public SwitchParameter Oldest
private const string queryOpenerTemplate = "<Query Id=\"{0}\" Path=\"{1}\"><Select Path=\"{1}\">*";
private const string queryCloser = "</Query>";
private const string SelectCloser = "</Select>";
private const string suppressOpener = "<Suppress>*";
private const string suppressOpener = "<Suppress Path=\"{1}\">*";
private const string suppressCloser = "</Suppress>";
private const char propOpen = '[';
private const char propClose = ']';
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,18 +189,23 @@ protected override void BeginProcessing()

switch (Context.LanguageMode)
{
case PSLanguageMode.ConstrainedLanguage:
if (!CoreTypes.Contains(type))
case PSLanguageMode.ConstrainedLanguage:
if (System.Management.Automation.Security.SystemPolicy.GetSystemLockdownPolicy() != System.Management.Automation.Security.SystemEnforcementMode.Audit)
{
if ((ComObject != null) || (Strict.IsPresent))
{
if (SystemPolicy.GetSystemLockdownPolicy() != SystemEnforcementMode.Audit)
{
ThrowTerminatingError(
new ErrorRecord(
new PSNotSupportedException(NewObjectStrings.CannotCreateTypeConstrainedLanguage),
"CannotCreateTypeConstrainedLanguage",
ErrorCategory.PermissionDenied,
targetObject: null));
}
ThrowTerminatingError(
new ErrorRecord(
new PSNotSupportedException(NewObjectStrings.CannotCreateTypeConstrainedLanguage),
"CannotCreateTypeConstrainedLanguage",
ErrorCategory.PermissionDenied,
targetObject: null));
}
}

break;
case PSLanguageMode.FullLanguage:
break;

SystemPolicy.LogWDACAuditMessage(
context: Context,
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,7 +78,7 @@ public ShowCommandCommandInfo(PSObject other)
{
// Simple case - the objects are still live because they came from in-proc. Just cast them back
this.CommandType = (CommandTypes)(other.Members["CommandType"].Value);
this.Module = other.Members["Module"].Value as ShowCommandModuleInfo;
this.Module = other.Members["Module"]?.Value as ShowCommandModuleInfo;
}
else
{
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -821,14 +821,14 @@ internal LocalRunspace LocalRunspace
{
get
{
if (_isRunspacePushed)
if (RunspaceRef == null)
{
returnRunspaceRef.OldRunspace as LocalRunspace;
returnnull;
}

if (RunspaceRef == null)
if (_isRunspacePushed)
{
returnnull;
returnRunspaceRef.OldRunspace as LocalRunspace;
}

return RunspaceRef.Runspace as LocalRunspace;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -412,7 +412,7 @@ private static ViewDefinition GetView(PSPropertyExpressionFactory expressionFact
{
ActiveTracer.WriteLine(
"NOT MATCH {0} NAME: {1}",
ControlBase.GetControlShapeName(vd.mainControl), (vd != null ? vd.name : string.Empty));
(vd != null ?ControlBase.GetControlShapeName(vd.mainControl) : "null"), (vd != null ? vd.name : string.Empty));
continue;
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -782,47 +782,47 @@ public enum PipelineResultTypes
/// <summary>
/// Default streaming behavior.
/// </summary>
None,
None = 0,

/// <summary>
/// Success output.
/// </summary>
Output,
Output = 1,

/// <summary>
/// Error output.
/// </summary>
Error,
Error = 2,

/// <summary>
/// Warning information stream.
/// </summary>
Warning,
Warning = 4,

/// <summary>
/// Verbose information stream.
/// </summary>
Verbose,
Verbose = 8,

/// <summary>
/// Debug information stream.
/// </summary>
Debug,
Debug = 16,

/// <summary>
/// Information information stream.
/// </summary>
Information,
Information = 32,

/// <summary>
/// All streams.
/// </summary>
All,
All = Output | Error | Warning | Verbose | Debug | Information,

/// <summary>
/// Redirect to nothing.
/// </summary>
Null
Null = 0
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletionsrc/System.Management.Automation/utils/StringUtil.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -243,7 +243,7 @@ internal static string VtSubstring(this string str, int startOffset, int length,
}
else
{
int capacity = length + prependStr?.Length ?? 0 + appendStr?.Length ?? 0;
int capacity = length +(prependStr?.Length ?? 0) +(appendStr?.Length ?? 0);
return new StringBuilder(prependStr, capacity)
.Append(str, startOffset, length)
.Append(appendStr)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp