mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-04 23:00:54 +00:00
cmake-gui: Fix crash when selecting a preset with a differing build dir
QCMake::setPreset() bound a reference to the selected preset's expanded data inside CMakePresetsGraph.ConfigurePresets and then called setBinaryDirectory(). When the selected preset's build directory holds a cache whose CMAKE_HOME_DIRECTORY differs from the current source directory (e.g. because the source path is reached through a symbolic link, since browsing keeps the link unresolved while the cache stores the real path), setBinaryDirectory() loads that cache and re-sets the source directory. That re-reads the presets graph via loadPresets(), which calls ClearPresets() and destroys the map entry, leaving the reference dangling. Subsequent access crashed with a use-after-free. Copy the expanded preset instead of holding a reference into the graph so it stays valid across setBinaryDirectory(). Fixes: #27927
This commit is contained in:
committed by
Brad King
parent
bb780342ef
commit
6862249daa
@@ -164,7 +164,7 @@ void QCMake::setPreset(QString const& name, bool setBinary)
|
|||||||
|
|
||||||
if (!name.isNull()) {
|
if (!name.isNull()) {
|
||||||
std::string presetName(name.toStdString());
|
std::string presetName(name.toStdString());
|
||||||
auto const& expandedPreset =
|
auto const expandedPreset =
|
||||||
this->CMakePresetsGraph.ConfigurePresets[presetName].Expanded;
|
this->CMakePresetsGraph.ConfigurePresets[presetName].Expanded;
|
||||||
if (expandedPreset) {
|
if (expandedPreset) {
|
||||||
if (setBinary && !expandedPreset->BinaryDir.empty()) {
|
if (setBinary && !expandedPreset->BinaryDir.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user