Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverity scan fixes (3.40 backport) #60328

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Validate inputs for export mesh algorithms
Avoid potential division by 0

(cherry picked from commit 1192f87)
nyalldawson committed Jan 28, 2025
commit 39d506bf7e98bfc53bdff06bf7e52721ba0b4e40
14 changes: 12 additions & 2 deletions src/analysis/processing/qgsalgorithmexportmesh.cpp
Original file line number Diff line number Diff line change
@@ -624,7 +624,12 @@ QVariantMap QgsExportMeshOnGridAlgorithm::processAlgorithm( const QVariantMap &p
}

// grid definition
double gridSpacing = parameterAsDouble( parameters, QStringLiteral( "GRID_SPACING" ), context );
const double gridSpacing = parameterAsDouble( parameters, QStringLiteral( "GRID_SPACING" ), context );
if ( qgsDoubleNear( gridSpacing, 0 ) )
{
throw QgsProcessingException( QObject::tr( "Grid spacing cannot be 0" ) );
}

QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral( "EXTENT" ), context );
if ( extent.isEmpty() )
extent = mTriangularMesh.extent();
@@ -826,7 +831,12 @@ QVariantMap QgsMeshRasterizeAlgorithm::processAlgorithm( const QVariantMap &para
}

// create raster
double pixelSize = parameterAsDouble( parameters, QStringLiteral( "PIXEL_SIZE" ), context );
const double pixelSize = parameterAsDouble( parameters, QStringLiteral( "PIXEL_SIZE" ), context );
if ( qgsDoubleNear( pixelSize, 0 ) )
{
throw QgsProcessingException( QObject::tr( "Pixel size cannot be 0" ) );
}

QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral( "EXTENT" ), context );
if ( extent.isEmpty() )
extent = mTriangularMesh.extent();