From af026b4b66c24531db3463b25b3987bd9d6a0e3a Mon Sep 17 00:00:00 2001 From: dabretin Date: Wed, 21 May 2014 11:30:33 +0200 Subject: [PATCH] Change "env" type of winpty_start_process env become a wstring witch can handle '\0' char (Buffer class putWString send the size of wstring, so it can handle CreateProcess environment format) --- include/winpty.h | 3 ++- libwinpty/winpty.cc | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/winpty.h b/include/winpty.h index b3cf1cea..396fef7a 100644 --- a/include/winpty.h +++ b/include/winpty.h @@ -25,6 +25,7 @@ #include #include +#include #ifdef WINPTY #define WINPTY_API __declspec(dllexport) @@ -77,7 +78,7 @@ WINPTY_API int winpty_start_process(winpty_t *pc, const wchar_t *appname, const wchar_t *cmdline, const wchar_t *cwd, - const wchar_t *env); + const std::wstring env); /* * Returns the exit code of the process started with winpty_start_process, diff --git a/libwinpty/winpty.cc b/libwinpty/winpty.cc index 97ec4447..a57dc7e7 100644 --- a/libwinpty/winpty.cc +++ b/libwinpty/winpty.cc @@ -461,7 +461,7 @@ WINPTY_API int winpty_start_process(winpty_t *pc, const wchar_t *appname, const wchar_t *cmdline, const wchar_t *cwd, - const wchar_t *env) + const std::wstring env) { WriteBuffer packet; @@ -469,7 +469,7 @@ WINPTY_API int winpty_start_process(winpty_t *pc, packet.putWString(appname ? appname : L""); packet.putWString(cmdline ? cmdline : L""); packet.putWString(cwd ? cwd : L""); - packet.putWString(env ? env : L""); + packet.putWString(env); packet.putWString(getDesktopFullName()); writePacket(pc, packet); return readInt32(pc);