Changeset 14723

Show
Ignore:
Timestamp:
06/17/08 18:25:45 (6 months ago)
Author:
rouault
Message:

Add test to avoid crash in GDALGetRandomRasterSample(). This is probably just a workaround. Needs probably more intelligent handling. Ticket to follow

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/gcore/gdal_misc.cpp

    r14168 r14723  
    709709    { 
    710710        CPLError( CE_Failure, CPLE_AppDefined, 
    711                   "GDALGetRandomSample(): returning because band" 
     711                  "GDALGetRandomRasterSample(): returning because band" 
    712712                  " appears degenerate." ); 
    713713 
     
    723723           && ((nBlockCount-1) / nSampleRate + 1) * nBlockPixels < nSamples ) 
    724724        nSampleRate--; 
     725 
     726    if ((nSamples / ((nBlockCount-1) / nSampleRate + 1)) == 0) 
     727    { 
     728        // FIXME ? EvenR: This is to avoid crash. Maybe fixable ? 
     729        CPLError( CE_Failure, CPLE_AppDefined, 
     730                  "GDALGetRandomRasterSample(): returning because band" 
     731                  " appears degenerate." ); 
     732 
     733        return FALSE; 
     734    } 
    725735 
    726736    nBlockSampleRate =