Commit ca8712b
committed
Fix: Prevent heap-use-after-free crash when importing XML via Script Editor (#8470)
This fixes a regression where importing an XML file via the Import button
in the Script Editor caused a heap-use-after-free crash, while drag-and-drop
of the same file worked fine.
Root cause:
In slot_import(), after clearing all tree widgets, the current item pointers
(mpCurrentTriggerItem, mpCurrentTimerItem, etc.) were left pointing to freed
memory. When slot_profileSaveAction() was subsequently called, it invoked
slot_saveEdits(), which attempted to save using these dangling pointers,
resulting in a crash when accessing freed QTreeWidgetItem objects.
Solution:
Clear all current item pointers immediately after clearing tree widgets and
BEFORE calling slot_profileSaveAction(). This ensures that the save
operations in slot_saveEdits() will safely early-return due to nullptr checks
at the beginning of each save function (saveTrigger(), saveTimer(), etc.).
This follows the same pattern used in runScheduledCleanReset() which has a
similar comment explaining the same safety measure.
The import still succeeds (the script is imported), but now without crashing.1 parent 034612d commit ca8712b
1 file changed
+5
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11500 | 11500 | | |
11501 | 11501 | | |
11502 | 11502 | | |
11503 | | - | |
11504 | | - | |
11505 | | - | |
11506 | | - | |
| 11503 | + | |
11507 | 11504 | | |
11508 | 11505 | | |
11509 | 11506 | | |
11510 | 11507 | | |
11511 | 11508 | | |
11512 | 11509 | | |
11513 | 11510 | | |
| 11511 | + | |
| 11512 | + | |
| 11513 | + | |
| 11514 | + | |
11514 | 11515 | | |
11515 | 11516 | | |
11516 | 11517 | | |
| |||
0 commit comments