[OpenVINO]Fix memory leak in IsDebugEnabled() under Windows (#5948)

* w

* w

Co-authored-by: modav <modav@microsoft.com>
This commit is contained in:
Moshe David 2020-11-27 01:10:37 +02:00 committed by GitHub
parent 4afdced775
commit e207589631
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,9 @@ bool IsDebugEnabled() {
#ifdef _WIN32
size_t env_name_len = 0;
char* env_name = nullptr;
return (_dupenv_s(&env_name, &env_name_len, "ORT_OPENVINO_ENABLE_DEBUG") == 0 && env_name != nullptr);
bool res = (_dupenv_s(&env_name, &env_name_len, "ORT_OPENVINO_ENABLE_DEBUG") == 0 && env_name != nullptr);
free(env_name);
return res;
#else
return (std::getenv("ORT_OPENVINO_ENABLE_DEBUG") != nullptr);
#endif