This revision was automatically updated to reflect the committed changes.
Closed by commit rG966fac1941ea: [clang][Tooling] Fix potential UB in 
ExpandResponseFilesCompilationDatabase (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71172/new/

https://reviews.llvm.org/D71172

Files:
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp


Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===================================================================
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -61,7 +61,9 @@
       llvm::StringSaver Saver(Alloc);
       llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS,
                                     llvm::StringRef(Cmd.Directory));
-      Cmd.CommandLine.assign(Argv.begin(), Argv.end());
+      // Don't assign directly, Argv aliases CommandLine.
+      std::vector<std::string> ExpandedArgv(Argv.begin(), Argv.end());
+      Cmd.CommandLine = std::move(ExpandedArgv);
     }
     return Cmds;
   }


Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===================================================================
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -61,7 +61,9 @@
       llvm::StringSaver Saver(Alloc);
       llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS,
                                     llvm::StringRef(Cmd.Directory));
-      Cmd.CommandLine.assign(Argv.begin(), Argv.end());
+      // Don't assign directly, Argv aliases CommandLine.
+      std::vector<std::string> ExpandedArgv(Argv.begin(), Argv.end());
+      Cmd.CommandLine = std::move(ExpandedArgv);
     }
     return Cmds;
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to