From dc80616bf6b5f5232fe30d96dcfa024da83ab0b9 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 15 Jul 2019 17:09:06 +0200 Subject: [PATCH] Fixed a use-after-free problem in object list this was uncovered by ASAN when attempting to Delete All objects with multiple instances --- src/slic3r/GUI/wxExtensions.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 1def2915cd..7e8a2d92df 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -806,8 +806,12 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item) if (node_parent) { if (node->m_type & (itInstanceRoot|itLayerRoot)) { - for (int i = node->GetChildCount() - 1; i >= (node->m_type & itInstanceRoot ? 1 : 0); i--) + // node can be deleted by the Delete, let's check its type while we safely can + bool is_instance_root = (node->m_type & itInstanceRoot); + + for (int i = node->GetChildCount() - 1; i >= (is_instance_root ? 1 : 0); i--) Delete(wxDataViewItem(node->GetNthChild(i))); + return parent; }