Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit ae7d82d

Browse files
committed
Fix(core): command parser
1 parent 6a4bdb9 commit ae7d82d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Core/Invoker.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ public static int ClientConsoleCommand(
9797
{
9898
var argString = Marshal.PtrToStringAnsi(pArgString);
9999

100-
if (argString is null)
100+
if (argString is null || argc < 1)
101101
{
102+
_sourceSharp.LogError("Failed to parse command: ArgS or ArgC is invalid");
102103
return null;
103104
}
104105

105-
var args = argc > 0 ? Enumerable.Range(0, argc - 1).Select(index =>
106+
var args = Enumerable.Range(0, argc).Select(index =>
106107
{
107108
if (Marshal.PtrToStructure(IntPtr.Add(pArgs, index * sizeof(int)), typeof(IntPtr)) is IntPtr strPtr)
108109
{
@@ -115,7 +116,7 @@ public static int ClientConsoleCommand(
115116
}
116117

117118
return string.Empty;
118-
}).ToArray() : new[] { argString };
119+
}).ToArray();
119120

120121
return new ConsoleCommand(argString, args, argc);
121122
}

0 commit comments

Comments
 (0)