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
This commit is contained in:
Seth Hillbrand 2024-05-26 07:33:30 -07:00
parent aeadec40b7
commit b2e0c2606f
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; delete m_currentSettings;
for( EDA_ITEM* item : m_previewItems ) for( EDA_ITEM* item : m_previewItems )
{
// Avoid referencing items after they are deleted (we don't control order)
item->SetParent( nullptr );
delete item; delete item;
}
} }