diff options
| author | _ov4 <ov4@ov4.org> | 2026-09-03 05:06:28 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-09-03 05:06:28 +0000 |
| commit | 7b27a3efde5d19c592ce674da26fdf0a6ef628a9 (patch) | |
| tree | 9fb3910ec96baf0583c67c41c9db3e88252c24ce | |
| parent | 816ea0743a9cd96e6e3888f446b4344afc932ef4 (diff) | |
fix UB
| -rw-r--r-- | src/path.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/path.cc b/src/path.cc index 1d14528..3ab8c0c 100644 --- a/src/path.cc +++ b/src/path.cc @@ -31,7 +31,8 @@ string path_unifier(const string &s, bool is_cmd) // single word, use path if (is_cmd && (s.find("/") == string::npos)) { - string path = getenv("PATH"); + const char *path_p = getenv("PATH"); + string path = (path_p != nullptr) ? path_p : ""; size_t i = 0, j = 0, l = path.size(); while (true) { |
