Skip to content

Commit

Permalink
Checks return code before nullifying db pointer.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwongu committed Mar 17, 2016
1 parent 426ed4c commit 011c3f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion boost_src/sqlite3pp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ namespace sqlite3pp
int rc = SQLITE_OK;
if (db_) {
rc = sqlite3_close(db_);
db_ = 0;
if (rc == SQLITE_OK) {
db_ = 0;
}
}

return rc;
Expand Down
4 changes: 3 additions & 1 deletion headeronly_src/sqlite3pp.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ namespace sqlite3pp
auto rc = SQLITE_OK;
if (db_) {
rc = sqlite3_close(db_);
db_ = nullptr;
if (rc == SQLITE_OK) {
db_ = nullptr;
}
}

return rc;
Expand Down
4 changes: 3 additions & 1 deletion src/sqlite3pp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ namespace sqlite3pp
auto rc = SQLITE_OK;
if (db_) {
rc = sqlite3_close(db_);
db_ = nullptr;
if (rc == SQLITE_OK) {
db_ = nullptr;
}
}

return rc;
Expand Down

0 comments on commit 011c3f5

Please sign in to comment.