Skip to content

Commit 9264902

Browse files
Fix bug with empty ROOT_INCLUDE_PATH in countIncludePaths test
1 parent 287346c commit 9264902

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

roottest/root/meta/countIncludePaths.C

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ int countIncludePaths()
1919

2020
// count paths coming from the ROOT_INCLUDE_PATH environment variable
2121
// and exclude them
22-
std::string envVar(std::getenv("ROOT_INCLUDE_PATH"));
23-
auto nEnvVarPaths = countSubstring(envVar, ":") + 1 - (envVar.back() == ':') - (envVar.front() == ':') ;
22+
int nEnvVarPaths = 0;
23+
auto *envVarCStr = std::getenv("ROOT_INCLUDE_PATH");
24+
if (envVarCStr) {
25+
std::string envVar(envVarCStr);
26+
nEnvVarPaths =
27+
countSubstring(envVar, ":") + 1 - (envVar.back() == ':') - (envVar.front() == ':');
28+
}
2429

2530
// At most 10
2631
auto nPaths = countSubstring(includePath, "-I");

0 commit comments

Comments
 (0)