diff options
author | Brad King <brad.king@kitware.com> | 2020-03-20 10:16:50 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-03-20 10:17:00 (GMT) |
commit | 94139ac58e2a4b1c4e3360b6d0da31ba9ba23c3c (patch) | |
tree | 6b5c0327c0f54ad107e5057894486c1b54be5aba /Source/cmMakefile.cxx | |
parent | 9bbea2344b058734047b0c889b2a6dae13c85cec (diff) | |
parent | 8affe9aa336b873e9c8e40ec5911ffe23c2ef03a (diff) | |
download | CMake-94139ac58e2a4b1c4e3360b6d0da31ba9ba23c3c.zip CMake-94139ac58e2a4b1c4e3360b6d0da31ba9ba23c3c.tar.gz CMake-94139ac58e2a4b1c4e3360b6d0da31ba9ba23c3c.tar.bz2 |
Merge topic 'export-repeat'
8affe9aa33 export: Fix use-after-free on multiple calls overwriting same FILE
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4494
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 831b1fb..5db2a3a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -32,6 +32,7 @@ #include "cmCustomCommandLines.h" #include "cmExecutionStatus.h" #include "cmExpandedCommandArgument.h" // IWYU pragma: keep +#include "cmExportBuildFileGenerator.h" #include "cmFileLockPool.h" #include "cmFunctionBlocker.h" #include "cmGeneratedFileStream.h" @@ -813,7 +814,7 @@ cmMakefile::GetEvaluationFiles() const return this->EvaluationFiles; } -std::vector<cmExportBuildFileGenerator*> +std::vector<std::unique_ptr<cmExportBuildFileGenerator>> const& cmMakefile::GetExportBuildFileGenerators() const { return this->ExportBuildFileGenerators; @@ -822,16 +823,21 @@ cmMakefile::GetExportBuildFileGenerators() const void cmMakefile::RemoveExportBuildFileGeneratorCMP0024( cmExportBuildFileGenerator* gen) { - auto it = std::find(this->ExportBuildFileGenerators.begin(), - this->ExportBuildFileGenerators.end(), gen); + auto it = + std::find_if(this->ExportBuildFileGenerators.begin(), + this->ExportBuildFileGenerators.end(), + [gen](std::unique_ptr<cmExportBuildFileGenerator> const& p) { + return p.get() == gen; + }); if (it != this->ExportBuildFileGenerators.end()) { this->ExportBuildFileGenerators.erase(it); } } -void cmMakefile::AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen) +void cmMakefile::AddExportBuildFileGenerator( + std::unique_ptr<cmExportBuildFileGenerator> gen) { - this->ExportBuildFileGenerators.push_back(gen); + this->ExportBuildFileGenerators.emplace_back(std::move(gen)); } namespace { |