Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix integer overflow in QgsCoordinateFormatter
  • Loading branch information
YoannQDQ authored and github-actions[bot] committed Apr 29, 2023
1 parent 0992b53 commit c3f8dd6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/qgscoordinateformatter.cpp
Expand Up @@ -117,7 +117,7 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutesSeconds( double val, int
wrappedX = wrappedX + 360.0;
}

const int precisionMultiplier = std::pow( 10.0, precision );
const double precisionMultiplier = std::pow( 10.0, precision );

int degreesX = int( std::fabs( wrappedX ) );
const double floatMinutesX = ( std::fabs( wrappedX ) - degreesX ) * 60.0;
Expand Down Expand Up @@ -199,7 +199,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutesSeconds( double val, int
wrappedY = wrappedY + 180.0;
}

const int precisionMultiplier = std::pow( 10.0, precision );
const double precisionMultiplier = std::pow( 10.0, precision );

int degreesY = int( std::fabs( wrappedY ) );
const double floatMinutesY = ( std::fabs( wrappedY ) - degreesY ) * 60.0;
Expand Down Expand Up @@ -278,7 +278,7 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutes( double val, int precisi
int degreesX = int( std::fabs( wrappedX ) );
double floatMinutesX = ( std::fabs( wrappedX ) - degreesX ) * 60.0;

const int precisionMultiplier = std::pow( 10.0, precision );
const double precisionMultiplier = std::pow( 10.0, precision );

//make sure rounding to specified precision doesn't create minutes >= 60
if ( std::round( floatMinutesX * precisionMultiplier ) >= 60 * precisionMultiplier )
Expand Down Expand Up @@ -341,7 +341,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutes( double val, int precisi
int degreesY = int( std::fabs( wrappedY ) );
double floatMinutesY = ( std::fabs( wrappedY ) - degreesY ) * 60.0;

const int precisionMultiplier = std::pow( 10.0, precision );
const double precisionMultiplier = std::pow( 10.0, precision );

//make sure rounding to specified precision doesn't create minutes >= 60
if ( std::round( floatMinutesY * precisionMultiplier ) >= 60 * precisionMultiplier )
Expand Down Expand Up @@ -398,7 +398,7 @@ QString QgsCoordinateFormatter::formatXAsDegrees( double val, int precision, For

const double absX = std::fabs( wrappedX );

const int precisionMultiplier = std::pow( 10.0, precision );
const double precisionMultiplier = std::pow( 10.0, precision );

QString hemisphere;
QString sign;
Expand Down Expand Up @@ -447,7 +447,7 @@ QString QgsCoordinateFormatter::formatYAsDegrees( double val, int precision, For

const double absY = std::fabs( wrappedY );

const int precisionMultiplier = std::pow( 10.0, precision );
const double precisionMultiplier = std::pow( 10.0, precision );

QString hemisphere;
QString sign;
Expand Down

0 comments on commit c3f8dd6

Please sign in to comment.