Skip to content

Commit 0ac9bbb

Browse files
NULL check environ before dereference
On UNIX, `clearenv` sets `environ` to NULL. So, NULL is a valid value for `environ`. Signed-off-by: Dušan Veljko <[email protected]>
1 parent d96016b commit 0ac9bbb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rocclr/utils/flags.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ bool Flag::init() {
119119
#else // !_WIN32
120120
#ifdef __APPLE__
121121
char** environ = *_NSGetEnviron();
122+
#endif // __APPLE__
123+
122124
if (environ == NULL) {
123125
return false;
124126
}
125-
#endif // __APPLE__
126-
127127
for (const char** p = const_cast<const char**>(environ); *p != NULL; ++p) {
128128
std::string var = *p;
129129
size_t pos = var.find('=');

0 commit comments

Comments
 (0)