r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 15 14:29:34 PST 2016


Author: joerg
Date: Fri Jan 15 16:29:34 2016
New Revision: 257947

URL: http://llvm.org/viewvc/llvm-project?rev=257947&view=rev
Log:
Avoid self-assignment of SmallString, trigger UB behavior down the road.

Modified:
    cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=257947&r1=257946&r2=257947&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Fri Jan 15 16:29:34 2016
@@ -290,9 +290,9 @@ static void SetInstallDir(SmallVectorImp
   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<const char *> argv, StringRef Tool) {




More information about the cfe-commits mailing list