From 93466fa1653191104c5e13231dfdc1640b272777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mr=C3=A1zek?= Date: Mon, 28 Dec 2020 17:13:15 +0100 Subject: [PATCH] Fix crash when adding 3D Models via Python --- pcbnew/footprint.cpp | 4 +--- pcbnew/plugins/kicad/pcb_parser.cpp | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 05ab434c42..9fe5f40fb2 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -968,13 +968,11 @@ unsigned FOOTPRINT::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const void FOOTPRINT::Add3DModel( FP_3DMODEL* a3DModel ) { - if( NULL == a3DModel ) + if( nullptr == a3DModel ) return; if( !a3DModel->m_Filename.empty() ) m_3D_Drawings.push_back( *a3DModel ); - - delete a3DModel; } diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index b9eac508c5..068042b9f6 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -3117,7 +3117,11 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments break; case T_model: - footprint->Add3DModel( parse3DModel() ); + { + FP_3DMODEL* model = parse3DModel(); + footprint->Add3DModel( model ); + delete model; + } break; case T_zone: