From e72db63c5e025d3936be5228c8c1ffe4deb3f15d Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Fri, 22 Nov 2013 14:11:11 +0000 Subject: [PATCH] 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. --- gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { -- 2.7.4