Skip to content

Commit

Permalink
Fix Coverity Scan issues (master only)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 22, 2024
1 parent 3b37f5a commit b51f137
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
9 changes: 4 additions & 5 deletions frmts/hdf5/s102dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,10 @@ bool S102Dataset::OpenQuality(GDALOpenInfo *poOpenInfo,
// I believe this is non-conformant.

// Escape potentials single-quote and double-quote with back-slash
const auto osEscapedCompName =
CPLString(oType.GetComponents()[0]->GetName())
.replaceAll("\\", "\\\\")
.replaceAll("'", "\\'")
.replaceAll("\"", "\\\"");
CPLString osEscapedCompName(oType.GetComponents()[0]->GetName());
osEscapedCompName.replaceAll("\\", "\\\\")
.replaceAll("'", "\\'")
.replaceAll("\"", "\\\"");

// Gets a view with that single component extracted.
poValuesArray = poValuesArray->GetView(
Expand Down
2 changes: 2 additions & 0 deletions gcore/gdaldataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,13 @@ GDALDataset::~GDALDataset()
if (m_poPrivate->hMutex != nullptr)
CPLDestroyMutex(m_poPrivate->hMutex);

// coverity[missing_lock]
CPLFree(m_poPrivate->m_pszWKTCached);
if (m_poPrivate->m_poSRSCached)
{
m_poPrivate->m_poSRSCached->Release();
}
// coverity[missing_lock]
CPLFree(m_poPrivate->m_pszWKTGCPCached);
if (m_poPrivate->m_poSRSGCPCached)
{
Expand Down
4 changes: 4 additions & 0 deletions gcore/gdalthreadsafedataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@ GDALThreadLocalDatasetCache::~GDALThreadLocalDatasetCache()
{
// Leak datasets when GDAL has been de-initialized
if (!m_poCache->empty())
{
// coverity[leaked_storage]
CPL_IGNORE_RET_VAL(m_poCache.release());
}
return;
}

Expand Down Expand Up @@ -747,6 +750,7 @@ GDALDataset *GDALThreadSafeDataset::RefUnderlyingDataset() const
// "Clone" the prototype dataset, which in 99% of the cases, involves
// doing a GDALDataset::Open() call to re-open it. Do that by temporarily
// dropping the lock that protects poCache->m_oCache.
// coverity[uninit_use_in_call]
oLock.unlock();
poTLSDS = m_poPrototypeDS->Clone(GDAL_OF_RASTER, /* bCanShareState=*/true);
if (poTLSDS)
Expand Down
21 changes: 11 additions & 10 deletions ogr/ogrsf_frmts/parquet/ogrparquetwriterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,17 +1291,18 @@ bool OGRParquetWriterLayer::IsArrowSchemaSupported(
osErrorMsg = "BinaryView not supported";
return false;
}
if (schema->format[0] == '+' && schema->format[1] == 'v' &&
schema->format[1] == 'l')
if (schema->format[0] == '+' && schema->format[1] == 'v')
{
osErrorMsg = "ListView not supported";
return false;
}
if (schema->format[0] == '+' && schema->format[1] == 'v' &&
schema->format[1] == 'L')
{
osErrorMsg = "LargeListView not supported";
return false;
if (schema->format[2] == 'l')
{
osErrorMsg = "ListView not supported";
return false;
}
else if (schema->format[2] == 'L')
{
osErrorMsg = "LargeListView not supported";
return false;
}
}
for (int64_t i = 0; i < schema->n_children; ++i)
{
Expand Down

0 comments on commit b51f137

Please sign in to comment.