Skip to content

Commit

Permalink
Merge pull request #10687 from rouault/fix_10685
Browse files Browse the repository at this point in the history
SQLite/GPKG: fix potential double-free issue when concurrently closing datasets when Spatialite is available
  • Loading branch information
rouault authored Aug 30, 2024
2 parents eb3cd75 + e8eaa68 commit 2114200
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ogr/ogrsf_frmts/sqlite/ogrsqlitedatasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <cstring>
#include <sys/stat.h>
#include <map>
#include <mutex>
#include <set>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -201,6 +202,11 @@ void OGRSQLiteBaseDataSource::FinishSpatialite()
{
if (hSpatialiteCtxt != nullptr)
{
// Current implementation of spatialite_cleanup_ex() (as of libspatialite 5.1)
// is not re-entrant due to the use of xmlCleanupParser()
// Cf https://groups.google.com/g/spatialite-users/c/tsfZ_GDrRKs/m/aj-Dt4xoBQAJ?utm_medium=email&utm_source=footer
static std::mutex oCleanupMutex;
std::lock_guard oLock(oCleanupMutex);
pfn_spatialite_cleanup_ex(hSpatialiteCtxt);
hSpatialiteCtxt = nullptr;
}
Expand Down

0 comments on commit 2114200

Please sign in to comment.