Skip to content

Commit 0e122f1

Browse files
[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
1 parent 71640be commit 0e122f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/libSwiftScan/SwiftCaching.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ expandSwiftInvocation(int argc, const char **argv, llvm::StringSaver &Saver,
253253
llvm::SmallVectorImpl<const char *> &ArgsStorage) {
254254
ArgsStorage.reserve(argc);
255255
for (int i = 0; i < argc; ++i)
256-
ArgsStorage.push_back(argv[i]);
256+
ArgsStorage.push_back(Saver.save(argv[i]).data());
257257
swift::driver::ExpandResponseFilesWithRetry(Saver, ArgsStorage);
258258

259259
// Drop the `-frontend` option if it is passed.

0 commit comments

Comments
 (0)