Skip to content
Permalink
Browse files
Fix Coverity divide by zero errors
  • Loading branch information
nyalldawson committed Mar 27, 2017
1 parent 943d1a2 commit 456fdc48a76c426cc0d12f81c9a57424a796d3be
Showing with 4 additions and 2 deletions.
  1. +2 −2 src/server/services/wms/qgswmsrenderer.cpp
  2. +2 −0 tests/src/core/testqgsrasterblock.cpp
@@ -1219,7 +1219,7 @@ namespace QgsWms
{
mapExtent.invert();
}
if ( !mapExtent.isEmpty() )
if ( !mapExtent.isEmpty() && height > 0 )
{
double mapWidthHeightRatio = mapExtent.width() / mapExtent.height();
double imageWidthHeightRatio = ( double )width / ( double )height;
@@ -1233,7 +1233,7 @@ namespace QgsWms
}
}

if ( width < 0 || height < 0 )
if ( width <= 0 || height <= 0 )
{
throw QgsException( QStringLiteral( "createImage: Invalid width / height parameters" ) );
}
@@ -134,6 +134,8 @@ void TestQgsRasterBlock::testWrite()
{
QgsRectangle extent = mpRasterLayer->extent();
int nCols = mpRasterLayer->width(), nRows = mpRasterLayer->height();
QVERIFY( nCols > 0 );
QVERIFY( nRows > 0 );
double tform[] =
{
extent.xMinimum(), extent.width() / nCols, 0.0,

0 comments on commit 456fdc4

Please sign in to comment.