Ensure PAINTER::Draw routines properly handle EDA_ITEM casting
EDA_ITEM is a child of VIEW_ITEM, so a static_cast is not appropriate, since in some cases it could be called with a non-EDA_ITEM argument. This was triggering an ASAN heap-buffer-overflow in GerbView.
This commit is contained in:
parent
0975f3817a
commit
61cdf3436b
|
@ -217,7 +217,10 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
|||
|
||||
bool KIGFX::WS_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||
{
|
||||
auto item = static_cast<const EDA_ITEM*>( aItem );
|
||||
auto item = dynamic_cast<const EDA_ITEM*>( aItem );
|
||||
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
|
|
|
@ -165,9 +165,12 @@ SCH_PAINTER::SCH_PAINTER( GAL* aGal ) :
|
|||
|
||||
bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
|
||||
{
|
||||
auto item2 = static_cast<const EDA_ITEM*>( aItem );
|
||||
auto item2 = dynamic_cast<const EDA_ITEM*>( aItem );
|
||||
auto item = const_cast<EDA_ITEM*>( item2 );
|
||||
|
||||
if( !item2 )
|
||||
return false;
|
||||
|
||||
#ifdef CONNECTIVITY_DEBUG
|
||||
|
||||
auto sch_item = dynamic_cast<SCH_ITEM*>( item );
|
||||
|
|
|
@ -104,7 +104,7 @@ void GERBVIEW_RENDER_SETTINGS::LoadDisplayOptions( const GBR_DISPLAY_OPTIONS& aO
|
|||
|
||||
COLOR4D GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
|
||||
{
|
||||
const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
|
||||
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
|
||||
static const COLOR4D transparent = COLOR4D( 0, 0, 0, 0 );
|
||||
const GERBER_DRAW_ITEM* gbrItem = nullptr;
|
||||
|
||||
|
@ -173,7 +173,10 @@ int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
|
|||
|
||||
bool GERBVIEW_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||
{
|
||||
const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
|
||||
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
|
||||
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
// the "cast" applied in here clarifies which overloaded draw() is called
|
||||
switch( item->Type() )
|
||||
|
|
Loading…
Reference in New Issue