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

Unified Diff: components/cronet/android/url_request_adapter.cc

Issue 1732493002: Prevent URLFetcher::AppendChunkedData from dereferencing NULL pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused variable Created 4 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 | « components/cronet/android/url_request_adapter.h ('k') | net/base/chunked_upload_data_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/url_request_adapter.cc
diff --git a/components/cronet/android/url_request_adapter.cc b/components/cronet/android/url_request_adapter.cc
index d6576374ba2a3dd62a6cff3aae2c799ba678d4b4..db9bd69deda3a38ab66c5033624c439afce12da4 100644
--- a/components/cronet/android/url_request_adapter.cc
+++ b/components/cronet/android/url_request_adapter.cc
@@ -129,14 +129,10 @@ void URLRequestAdapter::Start() {
void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes,
int bytes_len, bool is_last_chunk) {
DCHECK(OnNetworkThread());
- // Request could have completed and been destroyed on the network thread
- // while appendChunk was posting the task from an application thread.
- if (!url_request_) {
- VLOG(1) << "Cannot append chunk to destroyed request: "
- << url_.possibly_invalid_spec().c_str();
- return;
- }
- url_request_->AppendChunkToUpload(bytes.get(), bytes_len, is_last_chunk);
+ // If AppendData returns false, the request has been cancelled or completed
+ // without uploading the entire request body. Either way, that result will
+ // have been sent to the embedder, so there's nothing else to do here.
+ chunked_upload_writer_->AppendData(bytes.get(), bytes_len, is_last_chunk);
}
void URLRequestAdapter::OnInitiateConnection() {
@@ -166,7 +162,13 @@ void URLRequestAdapter::OnInitiateConnection() {
if (upload_data_stream_) {
url_request_->set_upload(std::move(upload_data_stream_));
} else if (chunked_upload_) {
- url_request_->EnableChunkedUpload();
+ scoped_ptr<net::ChunkedUploadDataStream> chunked_upload_data_stream(
+ new net::ChunkedUploadDataStream(0));
+ // Create a ChunkedUploadDataStream::Writer, which keeps a weak reference to
+ // the UploadDataStream, before passing ownership of the stream to the
+ // URLRequest.
+ chunked_upload_writer_ = chunked_upload_data_stream->CreateWriter();
+ url_request_->set_upload(std::move(chunked_upload_data_stream));
}
url_request_->SetPriority(priority_);
« no previous file with comments | « components/cronet/android/url_request_adapter.h ('k') | net/base/chunked_upload_data_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698