Fix a use-after-free in GetXcodeSDKPath

Introduced in https://reviews.llvm.org/D80595. Thanks Jonas for noticing!

Differential Revision: https://reviews.llvm.org/D80666
This commit is contained in:
Adrian Prantl 2020-05-27 14:26:15 -07:00
parent f46bb9dd5c
commit a57a67c59b
1 changed files with 2 additions and 3 deletions

View File

@ -370,7 +370,6 @@ llvm::StringRef HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
auto it = g_sdk_path.find(sdk.GetString());
if (it != g_sdk_path.end())
return it->second;
std::string path = GetXcodeSDK(sdk);
g_sdk_path.insert({sdk.GetString(), path});
return path;
auto it_new = g_sdk_path.insert({sdk.GetString(), GetXcodeSDK(sdk)});
return it_new.first->second;
}