[Lldb-commits] [PATCH] D92513: [lldb] Return the original path when tilde expansion fails.
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Dec 2 15:07:29 PST 2020
JDevlieghere created this revision.
JDevlieghere added a reviewer: teemperor.
JDevlieghere requested review of this revision.
I was playing around with changing the $HOME directory and when I provided a non-existing path LLDB would crash. I traced it down to the TildeExpressionResolver which would return an empty string when expansion fails, which in turn would be converted to the current working directory when calling MakeAbsolute.
https://reviews.llvm.org/D92513
Files:
lldb/source/Utility/TildeExpressionResolver.cpp
Index: lldb/source/Utility/TildeExpressionResolver.cpp
===================================================================
--- lldb/source/Utility/TildeExpressionResolver.cpp
+++ lldb/source/Utility/TildeExpressionResolver.cpp
@@ -73,11 +73,15 @@
#endif
}
+static void Assign(llvm::StringRef s, llvm::SmallVectorImpl<char> &v) {
+ v.clear();
+ v.append(s.begin(), s.end());
+}
+
bool TildeExpressionResolver::ResolveFullPath(
StringRef Expr, llvm::SmallVectorImpl<char> &Output) {
- Output.clear();
if (!Expr.startswith("~")) {
- Output.append(Expr.begin(), Expr.end());
+ Assign(Expr, Output);
return false;
}
@@ -85,8 +89,10 @@
StringRef Left =
Expr.take_until([](char c) { return path::is_separator(c); });
- if (!ResolveExact(Left, Output))
+ if (!ResolveExact(Left, Output)) {
+ Assign(Expr, Output);
return false;
+ }
Output.append(Expr.begin() + Left.size(), Expr.end());
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92513.309069.patch
Type: text/x-patch
Size: 955 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201202/2ac6da67/attachment.bin>
More information about the lldb-commits
mailing list