diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-05-08 21:18:24 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-05-09 09:38:09 +0200 |
commit | 415185de33fb07cbebf03236bf5a1db69cfb3d60 (patch) | |
tree | 56b2f60ca2533442acd6bd739fedf11c0c81e11d /vcl/source/outdev | |
parent | 7ad595c808fbe3d25dae7215e355ee14f03d2fd8 (diff) |
coverity#1250405 Division or modulo by float zero
another stab at this
Change-Id: I893f4b4a211a85718bf51bfbdb3e8bdb1df0066c
Reviewed-on: https://gerrit.libreoffice.org/37405
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r-- | vcl/source/outdev/map.cxx | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 619107c40978..f37116748603 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -256,48 +256,51 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, } else { + auto nXNumerator = aScaleX.GetNumerator(); + auto nYNumerator = aScaleY.GetNumerator(); + assert(nXNumerator != 0 && nYNumerator != 0); rMapRes.mfOffsetX *= aScaleX.GetDenominator(); - rMapRes.mfOffsetX /= aScaleX.GetNumerator(); + rMapRes.mfOffsetX /= nXNumerator; rMapRes.mfOffsetX += aOrigin.X(); rMapRes.mfOffsetY *= aScaleY.GetDenominator(); - rMapRes.mfOffsetY /= aScaleY.GetNumerator(); + rMapRes.mfOffsetY /= nYNumerator; rMapRes.mfOffsetY += aOrigin.Y(); BigInt aX( rMapRes.mnMapOfsX ); aX *= BigInt( aScaleX.GetDenominator() ); if ( rMapRes.mnMapOfsX >= 0 ) { - if ( aScaleX.GetNumerator() >= 0 ) - aX += BigInt( aScaleX.GetNumerator()/2 ); + if (nXNumerator >= 0) + aX += BigInt(nXNumerator / 2); else - aX -= BigInt( (aScaleX.GetNumerator()+1)/2 ); + aX -= BigInt((nXNumerator + 1) / 2); } else { - if ( aScaleX.GetNumerator() >= 0 ) - aX -= BigInt( (aScaleX.GetNumerator()-1)/2 ); + if (nXNumerator >= 0 ) + aX -= BigInt((nXNumerator - 1) / 2); else - aX += BigInt( aScaleX.GetNumerator()/2 ); + aX += BigInt(nXNumerator / 2); } - aX /= BigInt( aScaleX.GetNumerator() ); + aX /= BigInt(nXNumerator); rMapRes.mnMapOfsX = (long)aX + aOrigin.X(); BigInt aY( rMapRes.mnMapOfsY ); aY *= BigInt( aScaleY.GetDenominator() ); if( rMapRes.mnMapOfsY >= 0 ) { - if ( aScaleY.GetNumerator() >= 0 ) - aY += BigInt( aScaleY.GetNumerator()/2 ); + if (nYNumerator >= 0) + aY += BigInt(nYNumerator / 2); else - aY -= BigInt( (aScaleY.GetNumerator()+1)/2 ); + aY -= BigInt((nYNumerator + 1) / 2); } else { - if ( aScaleY.GetNumerator() >= 0 ) - aY -= BigInt( (aScaleY.GetNumerator()-1)/2 ); + if (nYNumerator >= 0) + aY -= BigInt((nYNumerator - 1) / 2); else - aY += BigInt( aScaleY.GetNumerator()/2 ); + aY += BigInt(nYNumerator / 2); } - aY /= BigInt( aScaleY.GetNumerator() ); + aY /= BigInt(nYNumerator); rMapRes.mnMapOfsY = (long)aY + aOrigin.Y(); } |