Skip to content

Commit 6de7413

Browse files
authored
[UR] Have ur_getenv return nullopt when empty (#17537)
The fact that an unset environment variable and an empty one have different behaviours is confusing and likely unintentional. In addition, it causes a crash in getenv_to_vec.
1 parent 37a7b45 commit 6de7413

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

unified-runtime/source/common/ur_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ std::optional<std::string> ur_getenv(const char *name) {
8686
return std::nullopt;
8787
#else
8888
const char *tmp_env = getenv(name);
89-
if (tmp_env != nullptr) {
89+
if (tmp_env != nullptr && tmp_env[0] != '\0') {
9090
return std::string(tmp_env);
9191
} else {
9292
return std::nullopt;

0 commit comments

Comments
 (0)