From b2c99dd9534e410196be39baabc788740e59091d Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sat, 5 Feb 2022 11:15:10 -0500 Subject: [PATCH] Fix some leaking objects identified by PVS Studio V773 (cherry picked from commit a7ebfc31f98e912f1e4f2acbcfacf1490731e6ea) --- pcbnew/tools/drawing_stackup_table_tool.cpp | 12 ++++++++---- utils/kicad2step/pcb/kicadpcb.cpp | 5 +---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pcbnew/tools/drawing_stackup_table_tool.cpp b/pcbnew/tools/drawing_stackup_table_tool.cpp index 50a5eb53bc..fbf49f176f 100644 --- a/pcbnew/tools/drawing_stackup_table_tool.cpp +++ b/pcbnew/tools/drawing_stackup_table_tool.cpp @@ -217,7 +217,8 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& std::vector> texts; // Style : Header - PCB_TEXT* headStyle = new PCB_TEXT( static_cast( m_frame->GetModel() ) ); + std::unique_ptr headStyle = + std::make_unique( static_cast( m_frame->GetModel() ) ); headStyle->SetLayer( Eco1_User ); headStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) ); headStyle->SetTextThickness( Millimeter2iu( 0.3 ) ); @@ -228,7 +229,8 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const wxPoint& headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); // Style : data - PCB_TEXT* dataStyle = new PCB_TEXT( static_cast( m_frame->GetModel() ) ); + std::unique_ptr dataStyle = + std::make_unique( static_cast( m_frame->GetModel() ) ); dataStyle->SetLayer( Eco1_User ); dataStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) ); dataStyle->SetTextThickness( Millimeter2iu( 0.1 ) ); @@ -382,7 +384,8 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint& wxPoint cursorPos = aOrigin; // Style : Section header - PCB_TEXT* headStyle = new PCB_TEXT( static_cast( m_frame->GetModel() ) ); + std::unique_ptr headStyle = + std::make_unique( static_cast( m_frame->GetModel() ) ); headStyle->SetLayer( Eco1_User ); headStyle->SetTextSize( wxSize( Millimeter2iu( 2.0 ), Millimeter2iu( 2.0 ) ) ); headStyle->SetTextThickness( Millimeter2iu( 0.4 ) ); @@ -392,7 +395,8 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint& headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); // Style : Data - PCB_TEXT* dataStyle = new PCB_TEXT( static_cast( m_frame->GetModel() ) ); + std::unique_ptr dataStyle = + std::make_unique( static_cast( m_frame->GetModel() ) ); dataStyle->SetLayer( Eco1_User ); dataStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) ); dataStyle->SetTextThickness( Millimeter2iu( 0.2 ) ); diff --git a/utils/kicad2step/pcb/kicadpcb.cpp b/utils/kicad2step/pcb/kicadpcb.cpp index ef4bae72b5..48050b21a4 100644 --- a/utils/kicad2step/pcb/kicadpcb.cpp +++ b/utils/kicad2step/pcb/kicadpcb.cpp @@ -384,18 +384,16 @@ bool KICADPCB::parseRect( SEXPR::SEXPR* data ) bool KICADPCB::parsePolygon( SEXPR::SEXPR* data ) { - KICADCURVE* poly = new KICADCURVE(); + std::unique_ptr poly = std::make_unique(); if( !poly->Read( data, CURVE_POLYGON ) ) { - delete poly; return false; } // reject any curves not on the Edge.Cuts layer if( poly->GetLayer() != LAYER_EDGE ) { - delete poly; return true; } @@ -418,7 +416,6 @@ bool KICADPCB::parsePolygon( SEXPR::SEXPR* data ) seg->m_end = pts.front(); m_curves.push_back( seg ); - return true; }