Index: content/browser/loader/resource_loader.cc |
diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc |
index 88c9c857d55e21cb6b8017de3f08821b32cf8964..55add725731dd2aa3a0e1267c61ac58c3f239fb1 100644 |
--- a/content/browser/loader/resource_loader.cc |
+++ b/content/browser/loader/resource_loader.cc |
@@ -597,7 +597,10 @@ void ResourceLoader::ReadMore(int* bytes_read) { |
ResourceRequestInfoImpl* info = GetRequestInfo(); |
DCHECK(!is_deferred()); |
- net::IOBuffer* buf; |
+ // Make sure we track the buffer in at least one place. This ensures it gets |
+ // deleted even in the case the request has already finished its job and |
+ // doesn't use the buffer. |
+ scoped_refptr<net::IOBuffer> buf; |
int buf_size; |
if (!handler_->OnWillRead(info->GetRequestID(), &buf, &buf_size, -1)) { |
Cancel(); |
@@ -607,12 +610,7 @@ void ResourceLoader::ReadMore(int* bytes_read) { |
DCHECK(buf); |
DCHECK(buf_size > 0); |
- // Make sure we track the buffer in at least one place. This ensures it gets |
- // deleted even in the case the request has already finished its job and |
- // doesn't use the buffer. |
- scoped_refptr<net::IOBuffer> tracked_buf(buf); |
- |
- request_->Read(tracked_buf.get(), buf_size, bytes_read); |
+ request_->Read(buf.get(), buf_size, bytes_read); |
// No need to check the return value here as we'll detect errors by |
// inspecting the URLRequest's status. |