mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-12 01:09:47 -06:00
CMake 3.16 and below allow multiple `export()` calls with the same output
file even without using `APPEND`. The implementation worked by accident
by leaking memory. Refactoring in commit 5444a8095d (cmGlobalGenerator:
modernize memrory managemenbt, 2019-12-29, v3.17.0-rc1~239^2) cleaned up
that memory leak and converted it to a use-after-free instead.
The problem is caused by using the `cmGlobalGenerator::BuildExportSets`
map to own `cmExportBuildFileGenerator` instances. It can own only
one instance per output FILE name at a time, so repeating use of the
same file now frees the old `cmExportBuildFileGenerator` instance
and leaves the pointer in the `cmMakefile::ExportBuildFileGenerators`
vector dangling. Move ownership of the instances into `cmMakefile`'s
vector since its entries are not replaced on a repeat output FILE.
In future work we should introduce a policy to error out on this case.
For now simply fix the use-after-free to restore CMake <= 3.16 behavior.
Fixes: #20469
16 lines
411 B
CMake
16 lines
411 B
CMake
include(RunCMake)
|
|
|
|
run_cmake(CustomTarget)
|
|
run_cmake(Empty)
|
|
run_cmake(Repeat)
|
|
run_cmake(TargetNotFound)
|
|
run_cmake(AppendExport)
|
|
run_cmake(OldIface)
|
|
run_cmake(NoExportSet)
|
|
run_cmake(ForbiddenToExportInterfaceProperties)
|
|
run_cmake(ForbiddenToExportImportedProperties)
|
|
run_cmake(ForbiddenToExportPropertyWithGenExp)
|
|
run_cmake(ExportPropertiesUndefined)
|
|
run_cmake(DependOnNotExport)
|
|
run_cmake(DependOnDoubleExport)
|