Avoid referencing parents after deletion

We look at the parent when deleting EDA_ITEMs but when clearing the test
sheet, we delete the sheet before the pin, causing a use-after-free.
Avoid this by setting parents to null in this case

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17961

(cherry picked from commit b2e0c2606f)
This commit is contained in:
Seth Hillbrand 2024-05-26 07:33:30 -07:00 committed by Jeff Young
parent 6ecfa65c4c
commit 9f9fa0dd8d
1 changed files with 4 additions and 0 deletions

View File

@ -106,7 +106,11 @@ PANEL_EESCHEMA_COLOR_SETTINGS::~PANEL_EESCHEMA_COLOR_SETTINGS()
delete m_currentSettings;
for( EDA_ITEM* item : m_previewItems )
{
// Avoid referencing items after they are deleted (we don't control order)
item->SetParent( nullptr );
delete item;
}
}