From 76c26d6ae168e298f8937a2ca2d1e1fa32ec66cf Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 11 Jan 2020 17:29:12 -0800 Subject: [PATCH] Remove unneeded unique_ptr The unique_ptr was useful when the original function took multiple paths which could de-scope the pointer. Current use allowed potential use-after-free. This is now re-written to pass pointer directly. --- pcbnew/array_creator.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pcbnew/array_creator.cpp b/pcbnew/array_creator.cpp index 22f32428bf..09138015f6 100644 --- a/pcbnew/array_creator.cpp +++ b/pcbnew/array_creator.cpp @@ -94,17 +94,17 @@ void ARRAY_CREATOR::Invoke() else { // Need to create a new item - std::unique_ptr new_item; + BOARD_ITEM* new_item; if( m_editModules ) { // Don't bother incrementing pads: the module won't update // until commit, so we can only do this once - new_item.reset( module->Duplicate( item, false ) ); + new_item = module->Duplicate( item, false ); } else { - new_item.reset( m_parent.GetBoard()->Duplicate( item ) ); + new_item = m_parent.GetBoard()->Duplicate( item ); // PCB items keep the same numbering @@ -118,7 +118,7 @@ void ARRAY_CREATOR::Invoke() // the undo command needs saving old area, if it is merged. } - this_item = new_item.get(); + this_item = new_item; if( new_item ) { @@ -134,7 +134,7 @@ void ARRAY_CREATOR::Invoke() }); } - commit.Add( new_item.release() ); + commit.Add( new_item ); } }