Browse Source

HeapFree() before GetLastError().

Successful HeapFree() will set the last error to 0 so the GetLastError()
call will not be meaningful.
Iain Patterson 7 years ago
parent
commit
1afadf5332
1 changed files with 1 additions and 1 deletions
  1. 1 1
      registry.cpp

+ 1 - 1
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;
   }