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

Unified Diff: net/quic/bidirectional_stream_quic_impl.cc

Issue 2032733002: Do not crash on null stream in writing to bidirectional streams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_crash
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/bidirectional_stream_quic_impl.cc
diff --git a/net/quic/bidirectional_stream_quic_impl.cc b/net/quic/bidirectional_stream_quic_impl.cc
index 3d1ae3cd4b31020e8638845d9e2ab2494acc7b27..ef5f9de7d03bdc3e11153c1d317326658c9ebd97 100644
--- a/net/quic/bidirectional_stream_quic_impl.cc
+++ b/net/quic/bidirectional_stream_quic_impl.cc
@@ -119,9 +119,16 @@ int BidirectionalStreamQuicImpl::ReadData(IOBuffer* buffer, int buffer_len) {
void BidirectionalStreamQuicImpl::SendData(const scoped_refptr<IOBuffer>& data,
int length,
bool end_stream) {
- DCHECK(stream_);
DCHECK(length > 0 || (length == 0 && end_stream));
+ if (!stream_) {
+ LOG(ERROR) << "Trying to send data when stream has been destroyed.";
mef 2016/06/01 21:53:15 when -> after
xunjieli 2016/06/01 23:08:22 Done.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError,
+ weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
mef 2016/06/01 21:53:15 nit: Should say ERR_UNEXPECTED in CL description.
xunjieli 2016/06/01 23:08:22 Done.
+ return;
+ }
+
std::unique_ptr<QuicConnection::ScopedPacketBundler> bundler;
if (!has_sent_headers_) {
DCHECK(!send_request_headers_automatically_);
@@ -149,9 +156,16 @@ void BidirectionalStreamQuicImpl::SendvData(
const std::vector<scoped_refptr<IOBuffer>>& buffers,
const std::vector<int>& lengths,
bool end_stream) {
- DCHECK(stream_);
DCHECK_EQ(buffers.size(), lengths.size());
+ if (!stream_) {
+ LOG(ERROR) << "Trying to send data when stream has been destroyed.";
mef 2016/06/01 21:53:15 when -> after
xunjieli 2016/06/01 23:08:22 Done.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError,
+ weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
+ return;
+ }
+
QuicConnection::ScopedPacketBundler bundler(
session_->connection(), QuicConnection::SEND_ACK_IF_PENDING);
if (!has_sent_headers_) {
@@ -233,12 +247,12 @@ void BidirectionalStreamQuicImpl::OnDataAvailable() {
void BidirectionalStreamQuicImpl::OnClose(QuicErrorCode error) {
DCHECK(stream_);
+
if (error == QUIC_NO_ERROR &&
stream_->stream_error() == QUIC_STREAM_NO_ERROR) {
ResetStream();
return;
}
- ResetStream();
mef 2016/06/01 21:53:15 Why no longer ResetStream() here?
xunjieli 2016/06/01 23:08:22 It is redundant. NotifyError will call ResetStream
NotifyError(was_handshake_confirmed_ ? ERR_QUIC_PROTOCOL_ERROR
: ERR_QUIC_HANDSHAKE_FAILED);
}

Powered by Google App Engine
This is Rietveld 408576698