Skip to content

Commit 26cda25

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

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lldb/include/lldb/Symbol/SwiftASTContext.h

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

12411241
/// Return the name of the OS-specific subdirectory containing the
12421242
/// Swift stdlib needed for \p target.
1243-
static llvm::StringRef GetSwiftStdlibOSDir(const llvm::Triple &target,
1244-
const llvm::Triple &host);
1243+
static std::string GetSwiftStdlibOSDir(const llvm::Triple &target,
1244+
const llvm::Triple &host);
12451245
};
12461246

12471247
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ 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,
75-
const llvm::Triple &host) {
74+
static std::string GetSwiftStdlibOSDir(const llvm::Triple &target,
75+
const llvm::Triple &host) {
7676
return SwiftASTContext::GetSwiftStdlibOSDir(target, host);
7777
}
7878
};

0 commit comments

Comments
 (0)