Skip to content

Commit

Permalink
Fix statement not set NULL on deletion
Browse files Browse the repository at this point in the history
Make local only variables static
  • Loading branch information
sapier authored and sapier committed Jun 25, 2014
1 parent 09ba047 commit 24face5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/rollback.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -1094,6 +1094,7 @@ class RollbackManager: public IRollbackManager
#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;
Expand All @@ -1117,6 +1118,8 @@ class RollbackManager: public IRollbackManager
if(dbh)
rc = sqlite3_close(dbh);

dbh = NULL;

if (rc != SQLITE_OK) {
errorstream << "RollbackManager::~RollbackManager(): "
<< "Failed to close database: rc=" << rc << std::endl;
Expand Down

0 comments on commit 24face5

Please sign in to comment.