From: Joerg Sonnenberger Date: Fri, 15 Jan 2016 22:29:34 +0000 (+0000) Subject: Avoid self-assignment of SmallString, trigger UB behavior down the road. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4dfd1e21cac64d18a4c5c7a53a447874dd382fb6;p=clang Avoid self-assignment of SmallString, trigger UB behavior down the road. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257947 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index ea218d5403..de14425d36 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -290,9 +290,9 @@ static void SetInstallDir(SmallVectorImpl &argv, if (CanonicalPrefixes) llvm::sys::fs::make_absolute(InstalledPath); - InstalledPath = llvm::sys::path::parent_path(InstalledPath); - if (llvm::sys::fs::exists(InstalledPath.c_str())) - TheDriver.setInstalledDir(InstalledPath); + StringRef InstalledPathParent(llvm::sys::path::parent_path(InstalledPath)); + if (llvm::sys::fs::exists(InstalledPathParent)) + TheDriver.setInstalledDir(InstalledPathParent); } static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {