szaszm commented on code in PR #2269:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2269#discussion_r4167620752
##########
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:
Well, the `_putenv_s, _wputenv_s, _tputenv_s` page indicated that narrow
_environ and wide string _wenviron environments are separate. Is it possible
that the syscalls widen the narrow string and modify _wenviron?
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s?view=msvc-170
https://learn.microsoft.com/en-us/cpp/c-runtime-library/environ-wenviron?view=msvc-170
--
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]