/* Dummy test to find buffer size */\r
unsigned long ret = RegQueryValueEx(key, value, 0, &type, NULL, envlen);\r
if (ret != ERROR_SUCCESS) {\r
+ *env = 0;\r
*envlen = 0;\r
/* The service probably doesn't have any environment configured */\r
if (ret == ERROR_FILE_NOT_FOUND) return 0;\r
}\r
\r
if (type != REG_MULTI_SZ) {\r
+ *env = 0;\r
+ *envlen = 0;\r
log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_INVALID_ENVIRONMENT_STRING_TYPE, value, service_name, 0);\r
return 2;\r
}\r
\r
*env = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, *envlen);\r
if (! *env) {\r
+ *envlen = 0;\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, value, _T("set_environment()"), 0);\r
return 3;\r
}\r
/* Actually get the strings */\r
ret = RegQueryValueEx(key, value, 0, &type, (unsigned char *) *env, envlen);\r
if (ret != ERROR_SUCCESS) {\r
- log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_QUERYVALUE_FAILED, value, error_string(GetLastError()), 0);\r
HeapFree(GetProcessHeap(), 0, *env);\r
*env = 0;\r
*envlen = 0;\r
+ log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_QUERYVALUE_FAILED, value, error_string(GetLastError()), 0);\r
return 4;\r
}\r
\r