aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-06-25 19:59:45 +0200
committersapier <Sapier at GMX dot net>2014-06-25 20:01:29 +0200
commit24face5249abfddd3de1e255ec4072677b39969d (patch)
tree8592efa25ff01f643a81242e5d3f1564ec5c3bc6
parent09ba047c0175adfaca4a6bccc41c8a0570c295db (diff)
downloadminetest-24face5249abfddd3de1e255ec4072677b39969d.tar.gz
minetest-24face5249abfddd3de1e255ec4072677b39969d.tar.bz2
minetest-24face5249abfddd3de1e255ec4072677b39969d.zip
Fix statement not set NULL on deletion
Make local only variables static
-rw-r--r--src/rollback.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/rollback.cpp b/src/rollback.cpp
index 36ebd729c..0af7aa4f7 100644
--- a/src/rollback.cpp
+++ b/src/rollback.cpp
@@ -36,17 +36,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define POINTS_PER_NODE (16.0)
-std::string dbp;
-sqlite3* dbh;
-sqlite3_stmt* dbs_insert;
-sqlite3_stmt* dbs_replace;
-sqlite3_stmt* dbs_select;
-sqlite3_stmt* dbs_select_range;
-sqlite3_stmt* dbs_select_withActor;
-sqlite3_stmt* dbs_knownActor_select;
-sqlite3_stmt* dbs_knownActor_insert;
-sqlite3_stmt* dbs_knownNode_select;
-sqlite3_stmt* dbs_knownNode_insert;
+static std::string dbp;
+static sqlite3* dbh = NULL;
+static sqlite3_stmt* dbs_insert = NULL;
+static sqlite3_stmt* dbs_replace = NULL;
+static sqlite3_stmt* dbs_select = NULL;
+static sqlite3_stmt* dbs_select_range = NULL;
+static sqlite3_stmt* dbs_select_withActor = NULL;
+static sqlite3_stmt* dbs_knownActor_select = NULL;
+static sqlite3_stmt* dbs_knownActor_insert = NULL;
+static sqlite3_stmt* dbs_knownNode_select = NULL;
+static sqlite3_stmt* dbs_knownNode_insert = NULL;
struct Stack {
int node;
@@ -1094,6 +1094,7 @@ public:
#define FINALIZE_STATEMENT(statement) \
if ( statement ) \
rc = sqlite3_finalize(statement); \
+ statement = NULL; \
if ( rc != SQLITE_OK ) \
errorstream << "RollbackManager::~RollbackManager():" \
<< "Failed to finalize: " << #statement << ": rc=" << rc << std::endl;
@@ -1117,6 +1118,8 @@ public:
if(dbh)
rc = sqlite3_close(dbh);
+ dbh = NULL;
+
if (rc != SQLITE_OK) {
errorstream << "RollbackManager::~RollbackManager(): "
<< "Failed to close database: rc=" << rc << std::endl;