Skip to content
Permalink
Browse files

Add check for int overflow on 32 bit systems

  • Loading branch information
elpaso committed Nov 27, 2018
1 parent d3d1805 commit b3ed482bc8f2ed1408d9ae1e834d53fff771edc9
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/providers/gdal/qgsgdalprovider.cpp
@@ -848,6 +848,15 @@ void QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi

// Allocate temporary block
size_t bufferSize = dataSize * static_cast<size_t>( tmpWidth ) * static_cast<size_t>( tmpHeight );
#ifdef Q_PROCESSOR_X86_32
// Safety check for 32 bit systems
qint64 _buffer_size = dataSize * static_cast<qint64>( tmpWidth ) * static_cast<qint64>( tmpHeight );
if ( _buffer_size != static_cast<qint64>( bufferSize ) )
{
QgsDebugMsg( QStringLiteral( "Integer overflow calculating buffer size on a 32 bit system." ) );
return;
}
#endif
char *tmpBlock = static_cast<char *>( qgsMalloc( bufferSize ) );
if ( ! tmpBlock )
{

0 comments on commit b3ed482

Please sign in to comment.
You can’t perform that action at this time.