Commit 8cfa0f76 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[1183] make dbparameters_ a scoped_ptr

so that failed constructor does not leak
parent bdebd1af
......@@ -49,7 +49,7 @@ struct SQLite3Parameters {
};
SQLite3Database::SQLite3Database(const std::string& filename,
const isc::dns::RRClass& rrclass) :
const isc::dns::RRClass& rrclass) :
dbparameters_(new SQLite3Parameters),
class_(rrclass.toText()),
database_name_("sqlite3_" +
......@@ -243,7 +243,7 @@ SQLite3Database::open(const std::string& name) {
}
checkAndSetupSchema(&initializer);
initializer.move(dbparameters_);
initializer.move(dbparameters_.get());
}
SQLite3Database::~SQLite3Database() {
......@@ -251,7 +251,6 @@ SQLite3Database::~SQLite3Database() {
if (dbparameters_->db_ != NULL) {
close();
}
delete dbparameters_;
}
void
......@@ -432,7 +431,7 @@ private:
void copyColumn(std::string (&data)[COLUMN_COUNT], int column) {
data[column] = convertToPlainChar(sqlite3_column_text(statement_,
column),
database_->dbparameters_);
database_->dbparameters_.get());
}
void bindZoneId(const int zone_id) {
......
......@@ -21,6 +21,7 @@
#include <exceptions/exceptions.h>
#include <boost/enable_shared_from_this.hpp>
#include <boost/scoped_ptr.hpp>
#include <string>
namespace isc {
......@@ -127,7 +128,7 @@ public:
private:
/// \brief Private database data
SQLite3Parameters* dbparameters_;
boost::scoped_ptr<SQLite3Parameters> dbparameters_;
/// \brief The class for which the queries are done
const std::string class_;
/// \brief Opens the database
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment