summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-07-28 02:39:15 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-07-28 02:39:15 +0100
commita42f896351509219c8c9df0d6368f84b77a9a0d3 (patch)
tree07b0fda95d1179baea5a2f2c4679df0fc58d8c95
parentFix length check in Metadata::in_scope (diff)
downloadslicer-a42f896351509219c8c9df0d6368f84b77a9a0d3.tar.bz2
slicer-a42f896351509219c8c9df0d6368f84b77a9a0d3.tar.xz
slicer-a42f896351509219c8c9df0d6368f84b77a9a0d3.zip
Don't pass potentially NULL PATH env to string_view
-rw-r--r--slicer/tool/slicer.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/slicer/tool/slicer.cpp b/slicer/tool/slicer.cpp
index 1a83519..a4439cb 100644
--- a/slicer/tool/slicer.cpp
+++ b/slicer/tool/slicer.cpp
@@ -29,7 +29,12 @@ defaultPostProcessor()
constexpr std::array<const std::pair<std::string_view, std::string_view>, 1> pps {{
{"clang-format", "-i"},
}};
- const std::string_view path {getenv("PATH")};
+ const auto path {[]() -> std::string_view {
+ if (auto p = getenv("PATH")) {
+ return p;
+ }
+ return "";
+ }()};
const auto pathBegin = make_split_iterator(path, first_finder(":", boost::is_equal()));
for (const auto & [cmd, opts] : pps) {
for (auto p = pathBegin; p != decltype(pathBegin) {}; ++p) {