aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-10-31 11:37:39 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-10-31 11:37:39 +0300
commitb2ac741e2b806f4565beeef34b12c95b6b3fdd41 (patch)
tree1a8eef9d4db83191db13948e001e44c7059cf8db
parent0417338bbbe28377a5c20e1b0d38dc802ea06b2b (diff)
Fix unhandled invalid_path exception in path_search()
-rw-r--r--libbutl/process.cxx29
1 files changed, 16 insertions, 13 deletions
diff --git a/libbutl/process.cxx b/libbutl/process.cxx
index bc05c5c..e2a8af1 100644
--- a/libbutl/process.cxx
+++ b/libbutl/process.cxx
@@ -291,10 +291,20 @@ namespace butl
}
s.append (f, fn);
- ep = path (move (s)); // Move back into result.
- if (norm)
- ep.normalize ();
+ // Assume that invalid path may not refer to an existing file.
+ //
+ try
+ {
+ ep = path (move (s)); // Move back into result.
+
+ if (norm)
+ ep.normalize ();
+ }
+ catch (const invalid_path&)
+ {
+ return false;
+ }
return exists (ep.string ().c_str ());
};
@@ -339,17 +349,10 @@ namespace butl
e = strchr (b, traits::path_separator);
// Empty path (i.e., a double colon or a colon at the beginning or end
- // of PATH) means search in the current dirrectory. Silently skip
- // invalid paths.
+ // of PATH) means search in the current directory.
//
- try
- {
- if (search (b, e != nullptr ? e - b : strlen (b)))
- return r;
- }
- catch (const invalid_path&)
- {
- }
+ if (search (b, e != nullptr ? e - b : strlen (b)))
+ return r;
}
// If we were given a fallback, try that.