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

Unified Diff: content/browser/indexed_db/indexed_db_backing_store.cc

Issue 1060613002: IndexedDB: Protect against use-after-free in ChainedBlobWriter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatted desctructor (one line) Created 5 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/indexed_db/indexed_db_backing_store.cc
diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc
index 0db7b6141b3d341fc3a0ad0766afc9f011721146..d50584c4eab1bc048c9b774d53369925f67053f1 100644
--- a/content/browser/indexed_db/indexed_db_backing_store.cc
+++ b/content/browser/indexed_db/indexed_db_backing_store.cc
@@ -2242,8 +2242,7 @@ class IndexedDBBackingStore::Transaction::ChainedBlobWriterImpl
: waiting_for_callback_(false),
database_id_(database_id),
backing_store_(backing_store),
- callback_(callback),
- aborted_(false) {
+ callback_(callback) {
blobs_.swap(*blobs);
iter_ = blobs_.begin();
backing_store->task_runner()->PostTask(
@@ -2261,8 +2260,8 @@ class IndexedDBBackingStore::Transaction::ChainedBlobWriterImpl
if (delegate_.get()) // Only present for Blob, not File.
content::BrowserThread::DeleteSoon(
content::BrowserThread::IO, FROM_HERE, delegate_.release());
- if (aborted_) {
- self_ref_ = NULL;
+ if (aborted_self_ref_.get()) {
+ aborted_self_ref_ = NULL;
return;
}
if (iter_->size() != -1 && iter_->size() != bytes_written)
@@ -2278,38 +2277,36 @@ class IndexedDBBackingStore::Transaction::ChainedBlobWriterImpl
void Abort() override {
if (!waiting_for_callback_)
return;
- self_ref_ = this;
- aborted_ = true;
+ aborted_self_ref_ = this;
}
private:
- ~ChainedBlobWriterImpl() override {}
+ ~ChainedBlobWriterImpl() override { DCHECK(!waiting_for_callback_); }
void WriteNextFile() {
DCHECK(!waiting_for_callback_);
- DCHECK(!aborted_);
+ DCHECK(!aborted_self_ref_.get());
if (iter_ == blobs_.end()) {
- DCHECK(!self_ref_.get());
callback_->Run(true);
return;
} else {
+ waiting_for_callback_ = true;
if (!backing_store_->WriteBlobFile(database_id_, *iter_, this)) {
+ waiting_for_callback_ = false;
callback_->Run(false);
return;
}
- waiting_for_callback_ = true;
}
}
bool waiting_for_callback_;
- scoped_refptr<ChainedBlobWriterImpl> self_ref_;
+ scoped_refptr<ChainedBlobWriterImpl> aborted_self_ref_;
WriteDescriptorVec blobs_;
WriteDescriptorVec::const_iterator iter_;
int64 database_id_;
IndexedDBBackingStore* backing_store_;
scoped_refptr<IndexedDBBackingStore::BlobWriteCallback> callback_;
scoped_ptr<FileWriterDelegate> delegate_;
- bool aborted_;
DISALLOW_COPY_AND_ASSIGN(ChainedBlobWriterImpl);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698