From a47e7df830181bc54a55a2d23978eae333708f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Veljko?= Date: Thu, 22 May 2025 18:13:50 +0200 Subject: [PATCH] NULL check `environ` before dereference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On UNIX, `clearenv` sets `environ` to NULL. So, NULL is a valid value for `environ`. Signed-off-by: DuĊĦan Veljko --- rocclr/utils/flags.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocclr/utils/flags.cpp b/rocclr/utils/flags.cpp index 31f8237888..730feba75e 100644 --- a/rocclr/utils/flags.cpp +++ b/rocclr/utils/flags.cpp @@ -119,11 +119,11 @@ bool Flag::init() { #else // !_WIN32 #ifdef __APPLE__ char** environ = *_NSGetEnviron(); +#endif // __APPLE__ + if (environ == NULL) { return false; } -#endif // __APPLE__ - for (const char** p = const_cast(environ); *p != NULL; ++p) { std::string var = *p; size_t pos = var.find('=');