aboutsummaryrefslogtreecommitdiff
path: root/src/path.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-09-03 05:18:46 +0000
committer_ov4 <ov4@ov4.org>2026-09-03 05:18:46 +0000
commit065ca31d261e55b26bcd4ddc5877b8a0ac9e77b7 (patch)
treee13a728c0fa0295ee84014ac5759b6aecd897276 /src/path.cc
parent7b27a3efde5d19c592ce674da26fdf0a6ef628a9 (diff)
safe_str
Diffstat (limited to 'src/path.cc')
-rw-r--r--src/path.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/path.cc b/src/path.cc
index 3ab8c0c..103e2c5 100644
--- a/src/path.cc
+++ b/src/path.cc
@@ -31,8 +31,7 @@ string path_unifier(const string &s, bool is_cmd)
// single word, use path
if (is_cmd && (s.find("/") == string::npos))
{
- const char *path_p = getenv("PATH");
- string path = (path_p != nullptr) ? path_p : "";
+ string path = safe_str(getenv("PATH"));
size_t i = 0, j = 0, l = path.size();
while (true)
{
@@ -65,7 +64,7 @@ int set_current_dir(const string &s)
string get_current_dir()
{
char buf[MAXLINE];
- return (string)(getcwd(buf, MAXLINE));
+ return safe_str(getcwd(buf, MAXLINE));
}