Browse Source

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.
Iain Patterson 8 years ago
parent
commit
e72db63c5e
1 changed files with 1 additions and 1 deletions
  1. 1 1
      gui.cpp

+ 1 - 1
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) {