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
…Gauss().

CID 164953 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)
  var_deref_op: Dereferencing null pointer aEntries.

Triggered in out of memory conditions.


git-svn-id: https://svn.osgeo.org/gdal/trunk@34761 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information
schwehr committed Jul 22, 2016
1 parent ab875c1 commit fc611ca
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions gdal/gcore/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,22 +647,30 @@ GDALResampleChunk32R_Gauss( double dfXRatioDstToSrc, double dfYRatioDstToSrc,
GDALColorEntry* aEntries = NULL;
int nTransparentIdx = -1;
if( poColorTable &&
!ReadColorTableAsArray(poColorTable, nEntryCount, aEntries, nTransparentIdx) )
!ReadColorTableAsArray(poColorTable, nEntryCount, aEntries,
nTransparentIdx) )
{
VSIFree(pafDstScanline);
return CE_Failure;
}

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

// Force c4 of nodata entry to 0 so that GDALFindBestEntry() identifies
// it as nodata value
// it as nodata value.
if( bHasNoData && fNoDataValue >= 0.0f && fNoDataValue < nEntryCount )
{
aEntries[static_cast<int>(fNoDataValue)].c4 = 0;
}
// Or if we have no explicit nodata, but a color table entry that is
// transparent, consider it as the nodata value
// transparent, consider it as the nodata value.
else if( !bHasNoData && nTransparentIdx >= 0 )
{
/*bHasNoData = TRUE; */ /* never read */
fNoDataValue = static_cast<float>(nTransparentIdx);
}

Expand Down

0 comments on commit fc611ca

Please sign in to comment.