From: Iain Patterson Date: Sun, 2 Mar 2014 12:28:46 +0000 (+0000) Subject: HeapFree() before GetLastError(). X-Git-Tag: v2.22~6 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=1afadf5332638a0526feefaa4151b240224ab036;p=nssm.git HeapFree() before GetLastError(). Successful HeapFree() will set the last error to 0 so the GetLastError() call will not be meaningful. --- diff --git a/registry.cpp b/registry.cpp index 2b111c3..6c1567c 100644 --- a/registry.cpp +++ b/registry.cpp @@ -214,10 +214,10 @@ int get_environment(TCHAR *service_name, HKEY key, TCHAR *value, TCHAR **env, un /* Actually get the strings */ ret = RegQueryValueEx(key, value, 0, &type, (unsigned char *) *env, envlen); if (ret != ERROR_SUCCESS) { + log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_QUERYVALUE_FAILED, value, error_string(GetLastError()), 0); HeapFree(GetProcessHeap(), 0, *env); *env = 0; *envlen = 0; - log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_QUERYVALUE_FAILED, value, error_string(GetLastError()), 0); return 4; }