From ccfec170b0d98d76163656baf10fd8b254a7639b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 28 Jun 2024 08:04:07 -0700 Subject: [PATCH] Modify some int32 ops to avoid potential overflow (cherry picked from commit f48a10535737b88b5a4e39f5ee751b027eedcb95) --- pcbnew/pcb_io/altium/altium_pcb.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pcbnew/pcb_io/altium/altium_pcb.cpp b/pcbnew/pcb_io/altium/altium_pcb.cpp index 20e8a29934..a858823b88 100644 --- a/pcbnew/pcb_io/altium/altium_pcb.cpp +++ b/pcbnew/pcb_io/altium/altium_pcb.cpp @@ -3482,7 +3482,7 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem, PCB_LAYER_ID aLay { // short vertical line aShape->SetShape( SHAPE_T::SEGMENT ); - VECTOR2I pointOffset( 0, ( aElem.topsize.y - aElem.topsize.x ) / 2 ); + VECTOR2I pointOffset( 0, ( aElem.topsize.y / 2 - aElem.topsize.x / 2 ) ); aShape->SetStart( aElem.position + pointOffset ); aShape->SetEnd( aElem.position - pointOffset ); } @@ -3490,7 +3490,7 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem, PCB_LAYER_ID aLay { // short horizontal line aShape->SetShape( SHAPE_T::SEGMENT ); - VECTOR2I pointOffset( ( aElem.topsize.x - aElem.topsize.y ) / 2, 0 ); + VECTOR2I pointOffset( ( aElem.topsize.x / 2 - aElem.topsize.y / 2 ), 0 ); aShape->SetStart( aElem.position + pointOffset ); aShape->SetEnd( aElem.position - pointOffset ); } @@ -3518,13 +3518,13 @@ void ALTIUM_PCB::HelperParsePad6NonCopper( const APAD6& aElem, PCB_LAYER_ID aLay if( aElem.topsize.x < aElem.topsize.y ) { - VECTOR2I offset( 0, ( aElem.topsize.y - aElem.topsize.x ) / 2 ); + VECTOR2I offset( 0, ( aElem.topsize.y / 2 - aElem.topsize.x / 2 ) ); aShape->SetStart( aElem.position + offset ); aShape->SetEnd( aElem.position - offset ); } else { - VECTOR2I offset( ( aElem.topsize.x - aElem.topsize.y ) / 2, 0 ); + VECTOR2I offset( ( aElem.topsize.x / 2 - aElem.topsize.y / 2 ), 0 ); aShape->SetStart( aElem.position + offset ); aShape->SetEnd( aElem.position - offset ); } @@ -4330,7 +4330,7 @@ void ALTIUM_PCB::ConvertFills6ToFootprintItemOnLayer( FOOTPRINT* aFootprint, con std::swap( width, height ); pad->SetSize( { width, height } ); - pad->SetPosition( ( aElem.pos1 + aElem.pos2 ) / 2 ); + pad->SetPosition( aElem.pos1 / 2 + aElem.pos2 / 2 ); } else { @@ -4352,8 +4352,8 @@ void ALTIUM_PCB::ConvertFills6ToFootprintItemOnLayer( FOOTPRINT* aFootprint, con shapePolys.Append( aElem.pos1.x - anchorPos.x, aElem.pos2.y - anchorPos.y ); shapePolys.Outline( 0 ).SetClosed( true ); - VECTOR2I center( ( aElem.pos1.x + aElem.pos2.x ) / 2 - anchorPos.x, - ( aElem.pos1.y + aElem.pos2.y ) / 2 - anchorPos.y ); + VECTOR2I center( aElem.pos1.x / 2 + aElem.pos2.x / 2 - anchorPos.x, + aElem.pos1.y / 2 + aElem.pos2.y / 2 - anchorPos.y ); shapePolys.Rotate( EDA_ANGLE( aElem.rotation, DEGREES_T ), center ); pad->AddPrimitivePoly( shapePolys, 0, true ); }