Index: net/base/upload_data_stream.cc |
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc |
index 9f7bdbb419a28d63610b9235c0d5fcd9a6b5952e..81e23c58cc4af662e587e55eaa563110d5e5b1a6 100644 |
--- a/net/base/upload_data_stream.cc |
+++ b/net/base/upload_data_stream.cc |
@@ -69,8 +69,13 @@ int UploadDataStream::FillBuf() { |
size_t bytes_copied = std::min(count, size_remaining); |
- memcpy(buf_->data() + buf_len_, &d[next_element_offset_], bytes_copied); |
- buf_len_ += bytes_copied; |
+ // Check if we have anything to copy first, because we are getting the |
+ // address of an element in |d| and that will throw an exception if |d| |
+ // is an empty vector. |
+ if (bytes_copied) { |
+ memcpy(buf_->data() + buf_len_, &d[next_element_offset_], bytes_copied); |
+ buf_len_ += bytes_copied; |
+ } |
if (bytes_copied == count) { |
advance_to_next_element = true; |