summaryrefslogtreecommitdiffstats
path: root/webkit/dom_storage
diff options
context:
space:
mode:
authoradamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 01:52:14 +0000
committeradamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 01:52:14 +0000
commit1dc55cd567ffa230519e7508269a747478b3653a (patch)
tree4386fac0dc6bc0ac5ea3994ea5ed88ad6574d46d /webkit/dom_storage
parentcfca118f581864e3e603708635b1a7685495f881 (diff)
downloadchromium_src-1dc55cd567ffa230519e7508269a747478b3653a.zip
chromium_src-1dc55cd567ffa230519e7508269a747478b3653a.tar.gz
chromium_src-1dc55cd567ffa230519e7508269a747478b3653a.tar.bz2
Fix uninitialized memory access in dom_storage_database_unittest.
Factor out initialization code into Init() method called by both constructors. Review URL: https://chromiumcodereview.appspot.com/9517008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124090 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/dom_storage')
-rw-r--r--webkit/dom_storage/dom_storage_database.cc13
-rw-r--r--webkit/dom_storage/dom_storage_database.h3
-rw-r--r--webkit/dom_storage/dom_storage_database_unittest.cc6
3 files changed, 13 insertions, 9 deletions
diff --git a/webkit/dom_storage/dom_storage_database.cc b/webkit/dom_storage/dom_storage_database.cc
index 3882f0c..988fbee 100644
--- a/webkit/dom_storage/dom_storage_database.cc
+++ b/webkit/dom_storage/dom_storage_database.cc
@@ -27,17 +27,20 @@ sql::ErrorDelegate* GetErrorHandlerForDomStorageDatabase() {
namespace dom_storage {
DomStorageDatabase::DomStorageDatabase(const FilePath& file_path)
- : file_path_(file_path),
- db_(NULL),
- failed_to_open_(false),
- tried_to_recreate_(false),
- known_to_be_empty_(false) {
+ : file_path_(file_path) {
// Note: in normal use we should never get an empty backing path here.
// However, the unit test for this class defines another constructor
// that will bypass this check to allow an empty path that signifies
// we should operate on an in-memory database for performance/reliability
// reasons.
DCHECK(!file_path_.empty());
+ Init();
+}
+
+void DomStorageDatabase::Init() {
+ failed_to_open_ = false;
+ tried_to_recreate_ = false;
+ known_to_be_empty_ = false;
}
DomStorageDatabase::~DomStorageDatabase() {
diff --git a/webkit/dom_storage/dom_storage_database.h b/webkit/dom_storage/dom_storage_database.h
index b9115fd..4183ec3 100644
--- a/webkit/dom_storage/dom_storage_database.h
+++ b/webkit/dom_storage/dom_storage_database.h
@@ -102,6 +102,9 @@ class DomStorageDatabase {
DomStorageDatabase();
#endif
+ // Initialization code shared between the two constructors of this class.
+ void Init();
+
// Path to the database on disk.
FilePath file_path_;
scoped_ptr<sql::Connection> db_;
diff --git a/webkit/dom_storage/dom_storage_database_unittest.cc b/webkit/dom_storage/dom_storage_database_unittest.cc
index f3a3db0..9a4ab2a 100644
--- a/webkit/dom_storage/dom_storage_database_unittest.cc
+++ b/webkit/dom_storage/dom_storage_database_unittest.cc
@@ -14,10 +14,8 @@
namespace dom_storage {
-DomStorageDatabase::DomStorageDatabase()
- : db_(NULL),
- failed_to_open_(false),
- tried_to_recreate_(false) {
+DomStorageDatabase::DomStorageDatabase() {
+ Init();
}
void CreateV1Table(sql::Connection* db) {