Skip to content

Commit 6ee95f7

Browse files
Tal500Tal Hadad
authored andcommitted
robustness under theoretical call to extractRelativePathFromAbsolute
1 parent 3b5a01c commit 6ee95f7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

simplecpp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,12 @@ static std::string extractRelativePathFromAbsolute(const std::string& absoluteSi
27442744
}
27452745
const std::size_t size = currentPrefix.size();
27462746
std::string relativeFromMeetingPath = normalizedAbsolutePath.substr(size, normalizedAbsolutePath.size() - size);
2747+
if (currentPrefix.empty() && !(startsWith_(absoluteSimplifiedPath, "/") && startsWith_(prefixSimplifiedAbsoluteDir, "/"))) {
2748+
// In the case that there is no common prefix path,
2749+
// and at not both of the paths start with `/` (can happen only in Windows paths on distinct partitions),
2750+
// return the absolute simplified path as is because no relative path can match.
2751+
return absoluteSimplifiedPath;
2752+
}
27472753
if (startsWith_(relativeFromMeetingPath, "/")) {
27482754
// omit the leading slash
27492755
relativeFromMeetingPath = relativeFromMeetingPath.substr(1, relativeFromMeetingPath.size());

0 commit comments

Comments
 (0)