diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-10 01:39:43 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-10 01:39:43 +0000 |
commit | 37f7c693be8f1c58f01e2bc06fbf31930fd6a7e1 (patch) | |
tree | fc4b48826a5c085d0a1c212b61bdcd86404f44fd /chrome | |
parent | 1bab1a4fd39ce327c402fe6e952f8ad1d4e31c30 (diff) | |
download | chromium_src-37f7c693be8f1c58f01e2bc06fbf31930fd6a7e1.zip chromium_src-37f7c693be8f1c58f01e2bc06fbf31930fd6a7e1.tar.gz chromium_src-37f7c693be8f1c58f01e2bc06fbf31930fd6a7e1.tar.bz2 |
Fix a memory error writing to a deleted URLFetcher instance.
BUG=40505
TEST=existing test under valgrind.
Review URL: http://codereview.chromium.org/1589028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44175 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/net/url_fetcher.cc | 11 | ||||
-rw-r--r-- | chrome/browser/net/url_fetcher_unittest.cc | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/chrome/browser/net/url_fetcher.cc b/chrome/browser/net/url_fetcher.cc index 350dd50..0d1fbac 100644 --- a/chrome/browser/net/url_fetcher.cc +++ b/chrome/browser/net/url_fetcher.cc @@ -156,6 +156,7 @@ void URLFetcher::Core::Start() { void URLFetcher::Core::Stop() { DCHECK_EQ(MessageLoop::current(), delegate_loop_); delegate_ = NULL; + fetcher_ = NULL; ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod(this, &Core::CancelURLRequest)); @@ -278,7 +279,10 @@ void URLFetcher::Core::OnCompletedURLRequest(const URLRequestStatus& status) { // after backoff time. int64 back_off_time = protect_entry_->UpdateBackoff(URLFetcherProtectEntry::FAILURE); - fetcher_->backoff_delay_ = base::TimeDelta::FromMilliseconds(back_off_time); + if (delegate_) { + fetcher_->backoff_delay_ = + base::TimeDelta::FromMilliseconds(back_off_time); + } ++num_retries_; // Restarts the request if we still need to notify the delegate. if (delegate_) { @@ -293,11 +297,12 @@ void URLFetcher::Core::OnCompletedURLRequest(const URLRequestStatus& status) { } } } else { - fetcher_->backoff_delay_ = base::TimeDelta(); protect_entry_->UpdateBackoff(URLFetcherProtectEntry::SUCCESS); - if (delegate_) + if (delegate_) { + fetcher_->backoff_delay_ = base::TimeDelta(); delegate_->OnURLFetchComplete(fetcher_, url_, status, response_code_, cookies_, data_); + } } } diff --git a/chrome/browser/net/url_fetcher_unittest.cc b/chrome/browser/net/url_fetcher_unittest.cc index 079bad5..6136c7e 100644 --- a/chrome/browser/net/url_fetcher_unittest.cc +++ b/chrome/browser/net/url_fetcher_unittest.cc @@ -18,6 +18,8 @@ using base::Time; using base::TimeDelta; +// TODO(eroman): Add a regression test for http://crbug.com/40505. + namespace { const wchar_t kDocRoot[] = L"chrome/test/data"; |