From 4d085c4aaeb7b689ebc9d3c1c682ded86071cd5f Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Wed, 17 Oct 2018 06:57:26 +0200 Subject: [PATCH] fix: don't call ReadRawDataComplete if it's not necessary (#15185) --- atom/browser/net/url_request_stream_job.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/atom/browser/net/url_request_stream_job.cc b/atom/browser/net/url_request_stream_job.cc index 8dcb22283e82..aac30522964a 100644 --- a/atom/browser/net/url_request_stream_job.cc +++ b/atom/browser/net/url_request_stream_job.cc @@ -153,13 +153,17 @@ void URLRequestStreamJob::OnData(std::vector&& buffer) { // NOLINT if (pending_buf_) { int len = BufferCopy(&write_buffer_, pending_buf_.get(), pending_buf_size_); write_buffer_.erase(write_buffer_.begin(), write_buffer_.begin() + len); + pending_buf_ = nullptr; + pending_buf_size_ = 0; ReadRawDataComplete(len); } } void URLRequestStreamJob::OnEnd() { ended_ = true; - ReadRawDataComplete(0); + if (pending_buf_) { + ReadRawDataComplete(0); + } } void URLRequestStreamJob::OnError(int error) {