mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-04 01:44:13 +02:00
52992b31eb
QETDiagramEditor::openBackupFiles() deleted the just-constructed QETProject when it failed to reach ProjectState::Ok, but had no continue/else after the delete - so addProject(project) ran unconditionally on the now-dangling pointer, and addProject() immediately dereferences it (new ProjectView(project), etc.). This matches the report exactly: clicking Cancel on the restore-files dialog (which just deletes the stale markers directly, never calling openBackupFiles()) works fine, while clicking OK crashes whenever any listed backup fails to open cleanly. Because the crash happens mid- loop, cleanup for that file (and any later ones in the same batch) never completes, which also explains the reporter's second complaint that the restore list kept growing across sessions. Fix: add the missing `continue` so a failed project is skipped instead of being passed use-after-free to addProject(). Verified: clean rebuild, only the intended object file recompiled and linked successfully. I attempted a live repro by crafting a malformed stale-file marker to force ProjectState != Ok and clicking OK under Xvfb, but this local build links against real KDE Frameworks (BUILD_WITH_KF5=ON, confirmed via CMakeCache.txt) rather than the in-tree nokde/kautosavefile.cpp reimplementation I initially targeted, which uses a different marker directory/naming scheme (~/.local/share/stalefiles/<app>/ via real KF5::KAutoSaveFile) that I wasn't able to reverse-engineer well enough in the time available to produce a matching malformed marker. Confidence in the fix instead rests on the code being an unambiguous, textbook use-after-free (this exact object is deleted on the line immediately above the missing continue) with a single-line, side-effect-free fix.