From: Iain Patterson Date: Fri, 22 Nov 2013 14:11:11 +0000 (+0000) Subject: Fixed environment when no newline was present. X-Git-Tag: v2.19~2 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=e72db63c5e025d3936be5228c8c1ffe4deb3f15d;p=nssm.git Fixed environment when no newline was present. If the user entered environment variables without a trailing newline we might have been left with only one trailing NULL and therefore the environment parameter would have been invalid. The path of least resistance is to add two trailing NULLs unconditionally. --- diff --git a/gui.cpp b/gui.cpp index 2642ad1..f9a553d 100644 --- a/gui.cpp +++ b/gui.cpp @@ -157,7 +157,7 @@ int install(HWND window) { unsigned long i, j; for (i = 0; i < envlen; i++) if (env[i] != '\r') newlen++; /* Must end with two NULLs. */ - newlen++; + newlen += 2; char *newenv = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, newlen); if (! newenv) {