Fix a couple of integer overflows.

This commit is contained in:
Jeff Young 2020-07-02 22:52:37 +01:00
parent 9940931b0f
commit 2cfd6ba978
2 changed files with 6 additions and 6 deletions

View File

@ -100,7 +100,7 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_CIRCLE& aB, int aC
const SEG side( vts[i], vts[ i + 1] );
VECTOR2I pn = side.NearestPoint( c );
int side_dist_sq = ( pn - c ).SquaredEuclideanNorm();
ecoord side_dist_sq = ( pn - c ).SquaredEuclideanNorm();
if( ( side_dist_sq == 0 || side_dist_sq < min_dist_sq ) && !aMTV && !aActual )
return true;

View File

@ -120,7 +120,7 @@ void TOOL_BASE::Reset( RESET_REASON aReason )
ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, bool aIgnorePads,
const std::vector<ITEM*> aAvoidItems)
const std::vector<ITEM*> aAvoidItems )
{
int tl = getView()->GetTopLayer();
@ -129,12 +129,12 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
static const int candidateCount = 5;
ITEM* prioritized[candidateCount];
int dist[candidateCount];
SEG::ecoord dist[candidateCount];
for( int i = 0; i < candidateCount; i++ )
{
prioritized[i] = 0;
dist[i] = std::numeric_limits<int>::max();
prioritized[i] = nullptr;
dist[i] = VECTOR2I::ECOORD_MAX;
}
ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
@ -164,7 +164,7 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
continue;
int itemDist = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
SEG::ecoord itemDist = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
if( !prioritized[2] || itemDist < dist[2] )
{