From f467c0769e7ef6ce52a511ff86aeb3b86bd3658f Mon Sep 17 00:00:00 2001 From: "hashimoto@chromium.org" Date: Tue, 20 Nov 2012 08:06:50 +0000 Subject: net: Add NULL check for SpdyHttpStream::request_info_ There are some code paths which calls SpdyHttpStream::GetUploadProgress() before the stream gets initialized. Also fixing some CHECKs to make them securer. BUG=161823 TEST=net_unittests Review URL: https://chromiumcodereview.appspot.com/11316094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168758 0039d316-1c4b-4281-b951-d872f2087c98 --- net/spdy/spdy_http_stream.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'net') diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc index 504ac1a..ab1b32f 100644 --- a/net/spdy/spdy_http_stream.cc +++ b/net/spdy/spdy_http_stream.cc @@ -79,7 +79,7 @@ const HttpResponseInfo* SpdyHttpStream::GetResponseInfo() const { } UploadProgress SpdyHttpStream::GetUploadProgress() const { - if (!request_info_->upload_data_stream) + if (!request_info_ || !request_info_->upload_data_stream) return UploadProgress(); return UploadProgress(request_info_->upload_data_stream->position(), @@ -271,7 +271,7 @@ void SpdyHttpStream::Cancel() { } int SpdyHttpStream::SendData() { - CHECK(request_info_->upload_data_stream); + CHECK(request_info_ && request_info_->upload_data_stream); CHECK_EQ(0, request_body_buf_->BytesRemaining()); // Read the data from the request body stream. @@ -295,7 +295,7 @@ bool SpdyHttpStream::OnSendHeadersComplete(int status) { } int SpdyHttpStream::OnSendBody() { - CHECK(request_info_->upload_data_stream); + CHECK(request_info_ && request_info_->upload_data_stream); const bool eof = request_info_->upload_data_stream->IsEOF(); if (request_body_buf_->BytesRemaining() > 0) { return stream_->WriteStreamData( @@ -313,7 +313,7 @@ int SpdyHttpStream::OnSendBody() { int SpdyHttpStream::OnSendBodyComplete(int status, bool* eof) { // |status| is the number of bytes written to the SPDY stream. - CHECK(request_info_->upload_data_stream); + CHECK(request_info_ && request_info_->upload_data_stream); *eof = false; if (status > 0) { -- cgit v1.1