From 97220f5b3f8b8c744466668c9689168953843594 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 May 2022 17:22:01 -0400 Subject: cmCTestSubmitHandler: avoid double fetching envvars Technically, they can change between these two calls, so use the verified pointer to assign to strings. Discovered by `clang-analyzer`. --- Source/CTest/cmCTestSubmitHandler.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index baeafc1..a8e0652 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -730,15 +730,15 @@ int cmCTestSubmitHandler::ProcessHandler() return -1; } - if (getenv("HTTP_PROXY")) { + if (char const* proxy = getenv("HTTP_PROXY")) { this->HTTPProxyType = 1; - this->HTTPProxy = getenv("HTTP_PROXY"); + this->HTTPProxy = proxy; if (getenv("HTTP_PROXY_PORT")) { this->HTTPProxy += ":"; this->HTTPProxy += getenv("HTTP_PROXY_PORT"); } - if (getenv("HTTP_PROXY_TYPE")) { - std::string type = getenv("HTTP_PROXY_TYPE"); + if (char const* proxy_type = getenv("HTTP_PROXY_TYPE")) { + std::string type = proxy_type; // HTTP/SOCKS4/SOCKS5 if (type == "HTTP") { this->HTTPProxyType = 1; -- cgit v0.12