Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: storage/browser/fileapi/sandbox_origin_database.cc

Issue 1639973002: FileSystem: Prevent iterator from being deleted after database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « storage/browser/fileapi/sandbox_origin_database.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/fileapi/sandbox_origin_database.cc
diff --git a/storage/browser/fileapi/sandbox_origin_database.cc b/storage/browser/fileapi/sandbox_origin_database.cc
index 85424a2351c8b3f08a5db910cc71491bc3f32d43..9bdadc40fb77b546ea566eea0b996a7125e3e5a8 100644
--- a/storage/browser/fileapi/sandbox_origin_database.cc
+++ b/storage/browser/fileapi/sandbox_origin_database.cc
@@ -331,16 +331,19 @@ bool SandboxOriginDatabase::GetLastPathNumber(int* number) {
return false;
}
// Verify that this is a totally new database, and initialize it.
- scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions()));
- iter->SeekToFirst();
- if (iter->Valid()) { // DB was not empty, but had no last path number!
- LOG(ERROR) << "File system origin database is corrupt!";
- return false;
+ {
+ // Scope the iterator to ensure it is deleted before database is closed.
+ scoped_ptr<leveldb::Iterator> iter(
+ db_->NewIterator(leveldb::ReadOptions()));
+ iter->SeekToFirst();
+ if (iter->Valid()) { // DB was not empty, but had no last path number!
+ LOG(ERROR) << "File system origin database is corrupt!";
+ return false;
+ }
}
// This is always the first write into the database. If we ever add a
// version number, they should go in in a single transaction.
- status =
- db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1"));
+ status = db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1"));
if (!status.ok()) {
HandleError(FROM_HERE, status);
return false;
« no previous file with comments | « storage/browser/fileapi/sandbox_origin_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698