Skip to content

Commit

Permalink
Check that aEntries is not null in overview.cpp:GDALResampleChunk32R_…
Browse files Browse the repository at this point in the history
…AverageT().

CID 164954 Explicit null dereferenced

Triggered in out of memory conditions.


git-svn-id: https://svn.osgeo.org/gdal/trunk@34760 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information
schwehr committed Jul 22, 2016
1 parent 096070c commit ab875c1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gdal/gcore/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ GDALResampleChunk32R_AverageT( double dfXRatioDstToSrc,
if( bBit2Grayscale )
poColorTable = NULL;


T tNoDataValue;
if( !bHasNoData )
tNoDataValue = 0;
Expand Down Expand Up @@ -290,12 +289,22 @@ GDALResampleChunk32R_AverageT( double dfXRatioDstToSrc,
GDALColorEntry* aEntries = NULL;
int nTransparentIdx = -1;
if( poColorTable &&
!ReadColorTableAsArray(poColorTable, nEntryCount, aEntries, nTransparentIdx) )
!ReadColorTableAsArray(poColorTable, nEntryCount, aEntries,
nTransparentIdx) )
{
VSIFree(pDstScanline);
VSIFree(panSrcXOffShifted);
return CE_Failure;
}

if( aEntries == NULL )
{
CPLError(CE_Failure, CPLE_OutOfMemory, "Unable to allocate aEntries");
VSIFree(pDstScanline);
VSIFree(panSrcXOffShifted);
return CE_Failure;
}

// Force c4 of nodata entry to 0 so that GDALFindBestEntry() identifies
// it as nodata value
if( bHasNoData && fNoDataValue >= 0.0f && tNoDataValue < nEntryCount )
Expand Down Expand Up @@ -2557,7 +2566,6 @@ GDALRegenerateOverviews( GDALRasterBandH hSrcBand,
"will probably lead to unexpected results.", pszResampling );
}


// If we have a nodata mask and we are doing something more complicated
// than nearest neighbouring, we have to fetch to nodata mask.

Expand Down Expand Up @@ -2869,7 +2877,6 @@ GDALRegenerateOverviews( GDALRasterBandH hSrcBand,
}



/************************************************************************/
/* GDALRegenerateOverviewsMultiBand() */
/************************************************************************/
Expand Down

0 comments on commit ab875c1

Please sign in to comment.