From 67376eb18a6be1aae934407ad9d86bd6427cc05c Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Thu, 18 Apr 2013 14:51:11 +0200 Subject: fix segfault in db.cpp:closeDb() --- datastore-leveldb/src/db.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'datastore-leveldb/src/db.cpp') diff --git a/datastore-leveldb/src/db.cpp b/datastore-leveldb/src/db.cpp index aae378f..a952512 100644 --- a/datastore-leveldb/src/db.cpp +++ b/datastore-leveldb/src/db.cpp @@ -46,10 +46,13 @@ leveldb::DB *getDB(std::string& name) { void closeDB() { - for (auto it = dbs.begin(); it != dbs.end(); ++it) { - std::cout << "Close " << (*it).first << std::endl; + std::cout << "Close Databases: "; + auto it = dbs.begin(); + while (it != dbs.end()) { + std::cout << (*it).first << ". "; delete (*it).second; - dbs.erase(it); + dbs.erase(it++); //post increment! } + std::cout << std::endl; } -- cgit v1.2.1