szaszm commented on code in PR #2269:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2269#discussion_r4167590610


##########
core-framework/common/src/utils/Environment.cpp:
##########
@@ -107,7 +107,13 @@ bool Environment::unsetEnvironmentVariable(const char* 
name) {
 
   Environment::accessEnvironment([&success, name](){
 #ifdef WIN32
-    success = SetEnvironmentVariableA(name, nullptr);
+  const bool crt_success = _putenv_s(name, "") == 0;
+  bool windows_success = SetEnvironmentVariableA(name, nullptr) != 0;
+  if (!windows_success && GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+    windows_success = true;
+  }
+
+  success = crt_success && windows_success;

Review Comment:
   Are you sure that there are two "environment variable" storages per process, 
one accessed through syscalls and one through the CRT? Do you have any sources 
for this information? I couldn't find any indication in the microsoft docs that 
show this to be the case, so I don't see why we need to do two different 
actions that are each supposed to be achieving the same outcome.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to