Skip to content

Commit

Permalink
Merge pull request #9154 from rouault/coverity_fixes
Browse files Browse the repository at this point in the history
2 Coverity fixes
  • Loading branch information
rouault authored Jan 29, 2024
2 parents 64cfe0c + 43dd934 commit a23fbee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/gdaltindex_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,13 +1000,13 @@ GDALDatasetH GDALTileIndex(const char *pszDest, int nSrcCount,
if (poSrcSRS->exportToProj4(&pszProj4) == OGRERR_NONE)
{
poFeature->SetField(i_SrcSRSName, pszProj4);
CPLFree(pszProj4);
}
else
{
poFeature->SetField(i_SrcSRSName,
poSrcDS->GetProjectionRef());
}
CPLFree(pszProj4);
}
}
else if (psOptions->eSrcSRSFormat == FORMAT_WKT)
Expand All @@ -1031,8 +1031,8 @@ GDALDatasetH GDALTileIndex(const char *pszDest, int nSrcCount,
if (poSrcSRS->exportToProj4(&pszProj4) == OGRERR_NONE)
{
poFeature->SetField(i_SrcSRSName, pszProj4);
CPLFree(pszProj4);
}
CPLFree(pszProj4);
}
else if (psOptions->eSrcSRSFormat == FORMAT_EPSG)
{
Expand Down
22 changes: 12 additions & 10 deletions frmts/gtiff/gt_wkt_srs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3703,20 +3703,22 @@ CPLErr GTIFMemBufFromSRS(OGRSpatialReferenceH hSRS,
{
hGTIF = GTIFNew(hTIFF);
if (hGTIF)
{
GTIFAttachPROJContext(hGTIF, OSRGetProjTLSContext());

if (hSRS != nullptr)
GTIFSetFromOGISDefnEx(hGTIF, hSRS, GEOTIFF_KEYS_STANDARD,
GEOTIFF_VERSION_1_0);
if (hSRS != nullptr)
GTIFSetFromOGISDefnEx(hGTIF, hSRS, GEOTIFF_KEYS_STANDARD,
GEOTIFF_VERSION_1_0);

if (bPixelIsPoint)
{
GTIFKeySet(hGTIF, GTRasterTypeGeoKey, TYPE_SHORT, 1,
RasterPixelIsPoint);
}
if (bPixelIsPoint)
{
GTIFKeySet(hGTIF, GTRasterTypeGeoKey, TYPE_SHORT, 1,
RasterPixelIsPoint);
}

GTIFWriteKeys(hGTIF);
GTIFFree(hGTIF);
GTIFWriteKeys(hGTIF);
GTIFFree(hGTIF);
}
}

/* -------------------------------------------------------------------- */
Expand Down

0 comments on commit a23fbee

Please sign in to comment.