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.
This commit is contained in:
Seth Hillbrand 2020-01-11 17:29:12 -08:00
parent 84d5d6c168
commit 76c26d6ae1
1 changed files with 5 additions and 5 deletions

View File

@ -94,17 +94,17 @@ void ARRAY_CREATOR::Invoke()
else
{
// Need to create a new item
std::unique_ptr<BOARD_ITEM> 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 );
}
}