Skip to content

Commit d2760d0

Browse files
committed
Fix a use-after-free in GetSwiftStdlibOSDir.
XcodeSDK::GetCanonicalName() no longer returns a constant string.
1 parent dd508af commit d2760d0

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lldb/include/lldb/Symbol/SwiftASTContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,8 @@ class SwiftASTContext : public TypeSystemSwift {
12191219

12201220
/// Return the name of the OS-specific subdirectory containing the
12211221
/// Swift stdlib needed for \p target.
1222-
static llvm::StringRef GetSwiftStdlibOSDir(const llvm::Triple &target,
1223-
const llvm::Triple &host);
1222+
static std::string GetSwiftStdlibOSDir(const llvm::Triple &target,
1223+
const llvm::Triple &host);
12241224
};
12251225

12261226
class SwiftASTContextForExpressions : public SwiftASTContext {

lldb/source/Symbol/SwiftASTContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,8 @@ static SDKTypeMinVersion GetSDKType(const llvm::Triple &target,
995995

996996
/// Return the name of the OS-specific subdirectory containing the
997997
/// Swift stdlib needed for \p target.
998-
StringRef SwiftASTContext::GetSwiftStdlibOSDir(const llvm::Triple &target,
999-
const llvm::Triple &host) {
998+
std::string SwiftASTContext::GetSwiftStdlibOSDir(const llvm::Triple &target,
999+
const llvm::Triple &host) {
10001000
auto sdk = GetSDKType(target, host);
10011001
XcodeSDK::Info sdk_info;
10021002
sdk_info.type = sdk.sdk_type;

lldb/unittests/Symbol/TestSwiftASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct SwiftASTContextTester : public SwiftASTContext {
7171
platform_sdk_path, swift_dir, swift_stdlib_os_dir, xcode_contents_path,
7272
toolchain_path, cl_tools_path);
7373
}
74-
static llvm::StringRef GetSwiftStdlibOSDir(const llvm::Triple &target,
74+
static std::string GetSwiftStdlibOSDir(const llvm::Triple &target,
7575
const llvm::Triple &host) {
7676
return SwiftASTContext::GetSwiftStdlibOSDir(target, host);
7777
}

0 commit comments

Comments
 (0)