Skip to content

Commit

Permalink
FileGDB: avoid Coverity Scan false positive (CID 1540071)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Mar 17, 2024
1 parent 2f54114 commit 3a65f65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 10 additions & 8 deletions ogr/ogrsf_frmts/filegdb/FGdbLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,8 +2080,7 @@ XMLSpatialReference(const OGRGeomFieldDefn *poSrcGeomFieldDefn,
CSLConstList papszOptions,
OGRGeomCoordinatePrecision &oCoordPrec)
{
const auto poSRS =
poSrcGeomFieldDefn ? poSrcGeomFieldDefn->GetSpatialRef() : nullptr;
const auto poSRS = poSrcGeomFieldDefn->GetSpatialRef();

/* We always need a SpatialReference */
CPLXMLNode *srs_xml =
Expand Down Expand Up @@ -2337,11 +2336,14 @@ bool FGdbLayer::CreateFeatureDataset(FGdbDataSource *pParentDataSource,
CPLAddXMLChild(defn_xml, extent_xml);

/* Add the SRS */
OGRGeomCoordinatePrecision oCoordPrec;
CPLXMLNode *srs_xml =
XMLSpatialReference(poSrcGeomFieldDefn, papszOptions, oCoordPrec);
if (srs_xml)
CPLAddXMLChild(defn_xml, srs_xml);
if (poSrcGeomFieldDefn)
{
OGRGeomCoordinatePrecision oCoordPrec;
CPLXMLNode *srs_xml =
XMLSpatialReference(poSrcGeomFieldDefn, papszOptions, oCoordPrec);
if (srs_xml)
CPLAddXMLChild(defn_xml, srs_xml);
}

/* Convert our XML tree into a string for FGDB */
char *defn_str = CPLSerializeXMLTree(xml_xml);
Expand Down Expand Up @@ -2614,7 +2616,7 @@ bool FGdbLayer::Create(FGdbDataSource *pParentDataSource,
* creation time */
CPLXMLNode *srs_xml = nullptr;
OGRGeomCoordinatePrecision oCoordPrec;
if (eType != wkbNone)
if (poSrcGeomFieldDefn)
{
CPLXMLNode *shape_xml =
CPLCreateXMLNode(fieldarray_xml, CXT_Element, "Field");
Expand Down
3 changes: 1 addition & 2 deletions ogr/ogrsf_frmts/openfilegdb/filegdb_coordprec_write.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ static OGRGeomCoordinatePrecision
GDBGridSettingsFromOGR(const OGRGeomFieldDefn *poSrcGeomFieldDefn,
CSLConstList aosLayerCreationOptions)
{
const auto poSRS =
poSrcGeomFieldDefn ? poSrcGeomFieldDefn->GetSpatialRef() : nullptr;
const auto poSRS = poSrcGeomFieldDefn->GetSpatialRef();

double dfXOrigin;
double dfYOrigin;
Expand Down

0 comments on commit 3a65f65

Please sign in to comment.