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

Side by Side Diff: headless/public/util/generic_url_request_job.cc

Issue 2854973004: Add extra size check to avoid unwanted Seg Fault (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "headless/public/util/generic_url_request_job.h" 5 #include "headless/public/util/generic_url_request_job.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 std::string GenericURLRequestJob::GetPostData() const { 271 std::string GenericURLRequestJob::GetPostData() const {
272 if (!request_->has_upload()) 272 if (!request_->has_upload())
273 return ""; 273 return "";
274 274
275 const net::UploadDataStream* stream = request_->get_upload(); 275 const net::UploadDataStream* stream = request_->get_upload();
276 if (!stream->GetElementReaders()) 276 if (!stream->GetElementReaders())
277 return ""; 277 return "";
278 278
279 if (stream->GetElementReaders()->size() == 0)
280 return "";
281
279 DCHECK_EQ(1u, stream->GetElementReaders()->size()); 282 DCHECK_EQ(1u, stream->GetElementReaders()->size());
280 const net::UploadBytesElementReader* reader = 283 const net::UploadBytesElementReader* reader =
281 (*stream->GetElementReaders())[0]->AsBytesReader(); 284 (*stream->GetElementReaders())[0]->AsBytesReader();
282 return std::string(reader->bytes(), reader->length()); 285 return std::string(reader->bytes(), reader->length());
283 } 286 }
284 287
285 const Request* GenericURLRequestJob::GetRequest() const { 288 const Request* GenericURLRequestJob::GetRequest() const {
286 return this; 289 return this;
287 } 290 }
288 291
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 344 }
342 345
343 mock_response_ = std::move(mock_response); 346 mock_response_ = std::move(mock_response);
344 347
345 OnFetchCompleteExtractHeaders(request_->url(), 348 OnFetchCompleteExtractHeaders(request_->url(),
346 mock_response_->response_data.data(), 349 mock_response_->response_data.data(),
347 mock_response_->response_data.size()); 350 mock_response_->response_data.size());
348 } 351 }
349 352
350 } // namespace headless 353 } // namespace headless
OLDNEW
« 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