Fixed broken environment on restart.
We were calling duplicate_environment() to copy the service's initial
environment prior to restarting it. However the duplicate_environment()
function modified its input by replacing = characters with NULLs. That
is not allowed; the memory returned by GetEnvironmentStrings() must be
treated as readonly.
After two restarts the application would run with a null environment and
probably crash.
We now copy the initial environment on to the heap and operate on the
copy, ensuring that the corruption does not occur.
Thanks Alessandro Gherardi.