the registry for parameters.\r
Thanks to Gerald Haider for noticing that installing a service with NSSM in a\r
path containing spaces was technically a security vulnerability.\r
+Thanks to Scott Ware for reporting a crash saving the environment on XP 32-bit.\r
\r
Licence\r
-------\r
duplicate_environment(newenv);
HeapFree(GetProcessHeap(), 0, newenv);
}
+
+/* Safely get a copy of the current environment. */
+TCHAR *copy_environment() {
+ TCHAR *rawenv = GetEnvironmentStrings();
+ if (! rawenv) return NULL;
+ TCHAR *env = copy_environment_block(rawenv);
+ FreeEnvironmentStrings(rawenv);
+ return env;
+}
int duplicate_environment(TCHAR *);
int test_environment(TCHAR *);
void duplicate_environment_strings(TCHAR *);
+TCHAR *copy_environment();
#endif
if (service->throttle_section_initialised) DeleteCriticalSection(&service->throttle_section);\r
if (service->throttle_timer) CloseHandle(service->throttle_timer);\r
if (service->hook_section_initialised) DeleteCriticalSection(&service->hook_section);\r
- if (service->initial_env) FreeEnvironmentStrings(service->initial_env);\r
+ if (service->initial_env) HeapFree(GetProcessHeap(), 0, service->initial_env);\r
HeapFree(GetProcessHeap(), 0, service);\r
}\r
\r
service->hook_section_initialised = true;\r
\r
/* Remember our initial environment. */\r
- service->initial_env = GetEnvironmentStrings();\r
+ service->initial_env = copy_environment();\r
\r
/* Remember our creation time. */\r
if (get_process_creation_time(GetCurrentProcess(), &service->nssm_creation_time)) ZeroMemory(&service->nssm_creation_time, sizeof(service->nssm_creation_time));\r