Skip to content

Commit

Permalink
Fix -Wnull-dereference warnings in -O2 -DDEBUG mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 4, 2025
1 parent 039399c commit 9f8aa24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions frmts/gti/gdaltileindexdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4122,6 +4122,7 @@ void GDALTileIndexDataset::InitBuffer(void *pData, int nBufXSize, int nBufYSize,
nBandNr == 0
? m_poMaskBand.get()
: cpl::down_cast<GDALTileIndexBand *>(papoBands[nBandNr - 1]);
CPLAssert(poVRTBand);
const double dfNoData = poVRTBand->m_dfNoDataValue;
if (dfNoData == 0.0)
{
Expand Down
13 changes: 8 additions & 5 deletions ogr/ogrsf_frmts/pg/ogrpglayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1943,9 +1943,12 @@ OGRErr OGRPGLayer::GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce)
OGRErr OGRPGLayer::GetExtent3D(int iGeomField, OGREnvelope3D *psExtent3D,
int bForce)
{
auto poLayerDefn = GetLayerDefn();

// If the geometry field is not 3D go for 2D
if (GetLayerDefn()->GetGeomFieldCount() > iGeomField &&
!OGR_GT_HasZ(GetLayerDefn()->GetGeomFieldDefn(iGeomField)->GetType()))
if (poLayerDefn->GetGeomFieldCount() > iGeomField &&
!OGR_GT_HasZ(CPLAssertNotNull(poLayerDefn->GetGeomFieldDefn(iGeomField))
->GetType()))
{
const OGRErr retVal{GetExtent(iGeomField, psExtent3D, bForce)};
psExtent3D->MinZ = std::numeric_limits<double>::infinity();
Expand All @@ -1955,8 +1958,8 @@ OGRErr OGRPGLayer::GetExtent3D(int iGeomField, OGREnvelope3D *psExtent3D,

CPLString osCommand;

if (iGeomField < 0 || iGeomField >= GetLayerDefn()->GetGeomFieldCount() ||
CPLAssertNotNull(GetLayerDefn()->GetGeomFieldDefn(iGeomField))
if (iGeomField < 0 || iGeomField >= poLayerDefn->GetGeomFieldCount() ||
CPLAssertNotNull(poLayerDefn->GetGeomFieldDefn(iGeomField))
->GetType() == wkbNone)
{
if (iGeomField != 0)
Expand All @@ -1968,7 +1971,7 @@ OGRErr OGRPGLayer::GetExtent3D(int iGeomField, OGREnvelope3D *psExtent3D,
}

OGRPGGeomFieldDefn *poGeomFieldDefn =
poFeatureDefn->GetGeomFieldDefn(iGeomField);
poLayerDefn->GetGeomFieldDefn(iGeomField);

if (TestCapability(OLCFastGetExtent3D))
{
Expand Down

0 comments on commit 9f8aa24

Please sign in to comment.