Skip to content

Commit 24face5

Browse files
sapiersapier
sapier
authored and
sapier
committedJun 25, 2014
Fix statement not set NULL on deletion
Make local only variables static
1 parent 09ba047 commit 24face5

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed
 

Diff for: ‎src/rollback.cpp

+14-11
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3636

3737
#define POINTS_PER_NODE (16.0)
3838

39-
std::string dbp;
40-
sqlite3* dbh;
41-
sqlite3_stmt* dbs_insert;
42-
sqlite3_stmt* dbs_replace;
43-
sqlite3_stmt* dbs_select;
44-
sqlite3_stmt* dbs_select_range;
45-
sqlite3_stmt* dbs_select_withActor;
46-
sqlite3_stmt* dbs_knownActor_select;
47-
sqlite3_stmt* dbs_knownActor_insert;
48-
sqlite3_stmt* dbs_knownNode_select;
49-
sqlite3_stmt* dbs_knownNode_insert;
39+
static std::string dbp;
40+
static sqlite3* dbh = NULL;
41+
static sqlite3_stmt* dbs_insert = NULL;
42+
static sqlite3_stmt* dbs_replace = NULL;
43+
static sqlite3_stmt* dbs_select = NULL;
44+
static sqlite3_stmt* dbs_select_range = NULL;
45+
static sqlite3_stmt* dbs_select_withActor = NULL;
46+
static sqlite3_stmt* dbs_knownActor_select = NULL;
47+
static sqlite3_stmt* dbs_knownActor_insert = NULL;
48+
static sqlite3_stmt* dbs_knownNode_select = NULL;
49+
static sqlite3_stmt* dbs_knownNode_insert = NULL;
5050

5151
struct Stack {
5252
int node;
@@ -1094,6 +1094,7 @@ class RollbackManager: public IRollbackManager
10941094
#define FINALIZE_STATEMENT(statement) \
10951095
if ( statement ) \
10961096
rc = sqlite3_finalize(statement); \
1097+
statement = NULL; \
10971098
if ( rc != SQLITE_OK ) \
10981099
errorstream << "RollbackManager::~RollbackManager():" \
10991100
<< "Failed to finalize: " << #statement << ": rc=" << rc << std::endl;
@@ -1117,6 +1118,8 @@ class RollbackManager: public IRollbackManager
11171118
if(dbh)
11181119
rc = sqlite3_close(dbh);
11191120

1121+
dbh = NULL;
1122+
11201123
if (rc != SQLITE_OK) {
11211124
errorstream << "RollbackManager::~RollbackManager(): "
11221125
<< "Failed to close database: rc=" << rc << std::endl;

0 commit comments

Comments
 (0)
Please sign in to comment.