On Tue, 9 May 2023 21:46:51 GMT, Roger Riggs <rri...@openjdk.org> wrote:
> Launching of processes on Windows using `ProcessCreateW` with a Unicode > character set requires the buffer to be writable. An access violation might > occur if `ProcessCreateW` writes to the command line string. The current > implementation fetches the command line string using JNI GetStringChars > returning a buffer that should not be modified. The code is unchanged since > 2015. There have not been any reported faults in that time. > > This change copies the command line to a separately allocation mutable buffer > to satisfy the Windows requirement. src/java.base/windows/native/libjava/ProcessImpl_md.c line 385: > 383: // Copy command line to mutable char buffer; > CreateProcessW may modify it > 384: jsize cmdLen = (*env)->GetStringLength(env, cmd); > 385: WCHAR *pcmdCopy = (WCHAR*)malloc(cmdLen * > sizeof(WCHAR)); Should this include null terminator, as it is interpreted as `LPWSTR` which is null-terminated? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13894#discussion_r1192655747