We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Generated code:
internal static unsafe winmdroot.Foundation.BOOL CreateProcess(string lpApplicationName, ref Span<char>lpCommandLine, winmdroot.Security.SECURITY_ATTRIBUTES? lpProcessAttributes, winmdroot.Security.SECURITY_ATTRIBUTES? lpThreadAttributes, winmdroot.Foundation.BOOL bInheritHandles, winmdroot.System.Threading.PROCESS_CREATION_FLAGS dwCreationFlags, void* lpEnvironment, string lpCurrentDirectory, in winmdroot.System.Threading.STARTUPINFOW lpStartupInfo, out winmdroot.System.Threading.PROCESS_INFORMATION lpProcessInformation) { if (lpCommandLine.LastIndexOf('\0') == -1)throw new ArgumentException("Required null terminator missing.", "lpCommandLine");
CreateProcess
"The lpCommandLine parameter can be NULL. In that case, the function uses the string pointed to by lpApplicationName as the command line."
NativeMethods.txt
CreateProcess PROCESS_CREATION_FLAGS
Span<char> spanCmdLine = new(null); bool ok = PInvoke.CreateProcess(path, ref spanCmdLine, lpProcessAttributes: null, lpThreadAttributes: null, bInheritHandles: false, Windows.Win32.System.Threading.PROCESS_CREATION_FLAGS.CREATE_SUSPENDED, lpEnvironment: null, lpCurrentDirectory: wd, startupInfo, out process);
System.ArgumentException HResult=0x80070057 Message=Required null terminator missing. (Parameter 'lpCommandLine')
0.2.188-beta
.NET 7
LangVersion
latest (C# 11)
The text was updated successfully, but these errors were encountered:
It seems our null termination check should include a null span check first. Something like this:
-if (lpCommandLine.LastIndexOf('\0') == -1) +if (lpCommandLine != null && lpCommandLine.LastIndexOf('\0') == -1)
Sorry, something went wrong.
Allow null arguments where null-terminated strings are required
ddf40c5
Fixes #874
Successfully merging a pull request may close this issue.
Actual behavior
Generated code:
Expected behavior
CreateProcess
"The lpCommandLine parameter can be NULL. In that case, the function uses the string pointed to by lpApplicationName as the command line."
Repro steps
NativeMethods.txt
content:Context
0.2.188-beta
.NET 7
LangVersion
(if explicitly set by project):latest (C# 11)
The text was updated successfully, but these errors were encountered: