POLY_GRID_PARTITION: detect a divide by 0, set a wxASSERT and avoid the crash.

This commit is contained in:
jean-pierre charras 2021-12-08 15:57:22 +01:00
parent 7ffd43a6f4
commit 0dad504e91
1 changed files with 6 additions and 0 deletions

View File

@ -151,6 +151,12 @@ bool POLY_GRID_PARTITION::checkClearance( const VECTOR2I& aP, int aClearance )
int POLY_GRID_PARTITION::rescale_trunc( int aNumerator, int aValue, int aDenominator ) const
{
int64_t numerator = (int64_t) aNumerator * (int64_t) aValue;
wxASSERT( aDenominator != 0 );
if( aDenominator == 0 ) // Avoid crash when divide by 0
aDenominator = 1;
return numerator / aDenominator;
}