llvm.org GIT mirror llvm / 343b271
[llvm-cov] Fix a use-after-free Taking a lock before appending to a vector does no good unless threads reading from the vector also take the lock, because the vector could be re-sized. I don't have a good isolated test for this. I found the issue with ASan while testing a large project. I'm working on a bot that does this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275516 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 4 years ago
1 changed file(s) with 1 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
150150 ErrorOr
151151 CodeCoverageTool::getSourceFile(StringRef SourceFile) {
152152 // If we've remapped filenames, look up the real location for this file.
153 std::unique_lock Guard{LoadedSourceFilesLock};
153154 if (!RemappedFilenames.empty()) {
154155 auto Loc = RemappedFilenames.find(SourceFile);
155156 if (Loc != RemappedFilenames.end())
163164 deferError(EC.message(), SourceFile);
164165 return EC;
165166 }
166 std::unique_lock Guard{LoadedSourceFilesLock};
167167 LoadedSourceFiles.emplace_back(SourceFile, std::move(Buffer.get()));
168168 return *LoadedSourceFiles.back().second;
169169 }