[libSwiftScan] Fix a use-after-free in replay instance creation

The response file expansion function doesn't return all the arguments
allocated using StringSaver produced. It only use the StringSaver to
save the newly expanded arguments. Need to make sure all the original
arguments are saved so they can be used later during replay.

rdar://121808135
This commit is contained in:
Steven Wu
2024-02-07 15:56:15 -08:00
parent 71640be109
commit 0e122f1aba

View File

@@ -253,7 +253,7 @@ expandSwiftInvocation(int argc, const char **argv, llvm::StringSaver &Saver,
llvm::SmallVectorImpl<const char *> &ArgsStorage) {
ArgsStorage.reserve(argc);
for (int i = 0; i < argc; ++i)
ArgsStorage.push_back(argv[i]);
ArgsStorage.push_back(Saver.save(argv[i]).data());
swift::driver::ExpandResponseFilesWithRetry(Saver, ArgsStorage);
// Drop the `-frontend` option if it is passed.