Skip to content

Commit 99d4e89

Browse files
committed
SQLite: avoid Coverity Scan warning
1 parent f93d612 commit 99d4e89

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,15 @@ bool OGRSQLiteBaseDataSource::InitSpatialite()
186186

187187
void OGRSQLiteBaseDataSource::FinishSpatialite()
188188
{
189+
// Current implementation of spatialite_cleanup_ex() (as of libspatialite 5.1)
190+
// is not re-entrant due to the use of xmlCleanupParser()
191+
// Cf https://groups.google.com/g/spatialite-users/c/tsfZ_GDrRKs/m/aj-Dt4xoBQAJ?utm_medium=email&utm_source=footer
192+
static std::mutex oCleanupMutex;
193+
std::lock_guard oLock(oCleanupMutex);
194+
189195
if (hSpatialiteCtxt != nullptr)
190196
{
191-
auto ctxt = hSpatialiteCtxt;
192-
{
193-
// Current implementation of spatialite_cleanup_ex() (as of libspatialite 5.1)
194-
// is not re-entrant due to the use of xmlCleanupParser()
195-
// Cf https://groups.google.com/g/spatialite-users/c/tsfZ_GDrRKs/m/aj-Dt4xoBQAJ?utm_medium=email&utm_source=footer
196-
static std::mutex oCleanupMutex;
197-
std::lock_guard oLock(oCleanupMutex);
198-
pfn_spatialite_cleanup_ex(ctxt);
199-
}
200-
// coverity[thread1_overwrites_value_in_field]
197+
pfn_spatialite_cleanup_ex(hSpatialiteCtxt);
201198
hSpatialiteCtxt = nullptr;
202199
}
203200
}

0 commit comments

Comments
 (0)