Skip to content

Commit 4a83da0

Browse files
committed
feat: support unicode environment strings
1 parent 5abd55e commit 4a83da0

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/core/judgingthread.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,14 +896,16 @@ void JudgingThread::runProgram() {
896896
CloseHandle(siex.StartupInfo.hStdError);
897897
});
898898

899-
QString environmentValues = environment.toStringList().join(QChar('\0')) + '\0';
899+
// Need 4 \0 to end the environment string, see CreateProcessW() documentation
900+
QString environmentValues = environment.toStringList().join(QChar('\0')) + '\0' + '\0' + '\0' + '\0';
900901

901902
QString commandLine = QString(R"("%1" %2)").arg(executableFile).arg(arguments);
902903

903904
if (! CreateProcessW(nullptr, (WCHAR *)(commandLine).utf16(), nullptr, &sa, TRUE,
904-
HIGH_PRIORITY_CLASS | EXTENDED_STARTUPINFO_PRESENT | DETACHED_PROCESS,
905-
(LPVOID)(environmentValues.toLocal8Bit().data()),
906-
(const WCHAR *)(workingDirectory.utf16()), (STARTUPINFO *)(&siex), &pi)) {
905+
HIGH_PRIORITY_CLASS | EXTENDED_STARTUPINFO_PRESENT | DETACHED_PROCESS |
906+
CREATE_UNICODE_ENVIRONMENT,
907+
(LPVOID)(environmentValues.utf16()), (const WCHAR *)(workingDirectory.utf16()),
908+
(STARTUPINFO *)(&siex), &pi)) {
907909
score = 0;
908910
result = CannotStartProgram;
909911
message = "Failed to create process";

0 commit comments

Comments
 (0)