Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Raise exception from the checking method directly
  • Loading branch information
pblottiere committed Apr 9, 2019
1 parent 46746a3 commit f482ddf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -734,11 +734,7 @@ namespace QgsWms
QImage *QgsRenderer::getMap( QgsMapSettings &mapSettings, HitTest *hitTest )
{
// check size
if ( !checkMaximumWidthHeight() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
QStringLiteral( "The requested map size is too large" ) );
}
checkMaximumWidthHeight();

// init layer restorer before doing anything
std::unique_ptr<QgsLayerRestorer> restorer;
Expand Down Expand Up @@ -1859,7 +1855,7 @@ namespace QgsWms
}
}

bool QgsRenderer::checkMaximumWidthHeight() const
void QgsRenderer::checkMaximumWidthHeight() const
{
//test if maxWidth / maxHeight are set in the project or as an env variable
//and WIDTH / HEIGHT parameter is in the range allowed range
Expand All @@ -1881,7 +1877,8 @@ namespace QgsWms
int width = this->width();
if ( wmsMaxWidth != -1 && width > wmsMaxWidth )
{
return false;
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
QStringLiteral( "The requested map width is too large" ) );
}

//HEIGHT
Expand All @@ -1902,7 +1899,8 @@ namespace QgsWms
int height = this->height();
if ( wmsMaxHeight != -1 && height > wmsMaxHeight )
{
return false;
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
QStringLiteral( "The requested map height is too large" ) );
}


Expand All @@ -1929,9 +1927,10 @@ namespace QgsWms
|| height <= 0
|| std::numeric_limits<int>::max() / static_cast<uint>( bytes_per_line ) < static_cast<uint>( height )
|| std::numeric_limits<int>::max() / sizeof( uchar * ) < static_cast<uint>( height ) )
return false;

return true;
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
QStringLiteral( "The requested map size is too large" ) );
}
}

void QgsRenderer::convertFeatureInfoToSia2045( QDomDocument &doc ) const
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsrenderer.h
Expand Up @@ -218,7 +218,7 @@ namespace QgsWms
/**
* Checks WIDTH/HEIGHT values against MaxWidth and MaxHeight
\returns true if width/height values are okay*/
bool checkMaximumWidthHeight() const;
void checkMaximumWidthHeight() const;

//! Converts a feature info xml document to SIA2045 norm
void convertFeatureInfoToSia2045( QDomDocument &doc ) const;
Expand Down

0 comments on commit f482ddf

Please sign in to comment.