@@ -67,6 +67,7 @@ QgsRasterProjector::QgsRasterProjector()
6767}
6868
6969QgsRasterProjector::QgsRasterProjector ( const QgsRasterProjector &projector )
70+ : QgsRasterInterface( 0 )
7071{
7172 mSrcCRS = projector.mSrcCRS ;
7273 mDestCRS = projector.mDestCRS ;
@@ -194,7 +195,7 @@ void QgsRasterProjector::calc()
194195 }
195196 // What is the maximum reasonable size of transformatio matrix?
196197 // TODO: consider better when to break - ratio
197- if ( mCPRows * mCPCols > 0.0625 * mDestRows * mDestCols )
198+ if ( mCPRows * mCPCols > 0.25 * mDestRows * mDestCols )
198199 {
199200 QgsDebugMsg ( " Too large CP matrix" );
200201 mApproximate = false ;
@@ -679,13 +680,20 @@ void * QgsRasterProjector::readBlock( int bandNo, QgsRectangle const & extent,
679680
680681 if ( !inputData ) return 0 ;
681682
682- int pixelSize = mInput ->typeSize ( mInput ->dataType ( bandNo ) ) / 8 ;
683+ size_t pixelSize = mInput ->typeSize ( mInput ->dataType ( bandNo ) ) / 8 ;
683684
684- int inputSize = pixelSize * srcCols () * srcRows ();
685+ size_t inputSize = pixelSize * srcCols () * srcRows ();
685686
686- int outputSize = width * height * pixelSize;
687+ size_t outputSize = width * height * pixelSize;
687688 void * outputData = malloc ( outputSize );
688689
690+ // Check for allcoation error
691+ if ( ! outputData )
692+ {
693+ QgsDebugMsg ( QString ( " Couldn't malloc %1 bytes!" ).arg ( outputSize ) );
694+ free ( inputData );
695+ return 0 ;
696+ }
689697 // TODO: fill by transparent
690698
691699 int srcRow, srcCol;
@@ -694,8 +702,8 @@ void * QgsRasterProjector::readBlock( int bandNo, QgsRectangle const & extent,
694702 for ( int j = 0 ; j < width; ++j )
695703 {
696704 srcRowCol ( i, j, &srcRow, &srcCol );
697- int srcIndex = pixelSize * ( srcRow * mSrcCols + srcCol );
698- int destIndex = pixelSize * ( i * width + j );
705+ size_t srcIndex = pixelSize * ( srcRow * mSrcCols + srcCol );
706+ size_t destIndex = pixelSize * ( i * width + j );
699707
700708 if ( srcIndex >= inputSize || destIndex >= outputSize ) continue ; // should not happen
701709
0 commit comments