summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-11 06:23:23 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-11 06:23:23 +0000
commitdb3e995390dc474c2aedf378a4b37675daf1a867 (patch)
tree23c76d5f6f09740c2b5eb1b46d61e5dc5fe9139c /net/spdy
parentb321a9d3142ebc2cadbfc3d58a7b39afe0b07286 (diff)
downloadchromium_src-db3e995390dc474c2aedf378a4b37675daf1a867.zip
chromium_src-db3e995390dc474c2aedf378a4b37675daf1a867.tar.gz
chromium_src-db3e995390dc474c2aedf378a4b37675daf1a867.tar.bz2
[SPDY] Fix crash in SpdyHttpStream::GetUploadProgress()
It should be checking request_info_ before calling HasUploadData(). This bug was introduced by r202703 Add comment for HasUploadData(). BUG=248114 R=rch@chromium.org Review URL: https://codereview.chromium.org/15851011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/spdy_http_stream.cc2
-rw-r--r--net/spdy/spdy_http_stream.h1
-rw-r--r--net/spdy/spdy_http_stream_spdy2_unittest.cc9
-rw-r--r--net/spdy/spdy_http_stream_spdy3_unittest.cc9
4 files changed, 20 insertions, 1 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index 5bcd82c..7b3100b 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -97,7 +97,7 @@ const HttpResponseInfo* SpdyHttpStream::GetResponseInfo() const {
}
UploadProgress SpdyHttpStream::GetUploadProgress() const {
- if (!HasUploadData())
+ if (!request_info_ || !HasUploadData())
return UploadProgress();
return UploadProgress(request_info_->upload_data_stream->position(),
diff --git a/net/spdy/spdy_http_stream.h b/net/spdy/spdy_http_stream.h
index 34483d0..1ad8576 100644
--- a/net/spdy/spdy_http_stream.h
+++ b/net/spdy/spdy_http_stream.h
@@ -94,6 +94,7 @@ class NET_EXPORT_PRIVATE SpdyHttpStream : public SpdyStream::Delegate,
virtual void OnClose(int status) OVERRIDE;
private:
+ // Must be called only when |request_info_| is non-NULL.
bool HasUploadData() const;
void OnStreamCreated(const CompletionCallback& callback, int rv);
diff --git a/net/spdy/spdy_http_stream_spdy2_unittest.cc b/net/spdy/spdy_http_stream_spdy2_unittest.cc
index 06bab80..581d530 100644
--- a/net/spdy/spdy_http_stream_spdy2_unittest.cc
+++ b/net/spdy/spdy_http_stream_spdy2_unittest.cc
@@ -147,6 +147,15 @@ class SpdyHttpStreamSpdy2Test : public testing::Test {
scoped_refptr<TransportSocketParams> transport_params_;
};
+// SpdyHttpStream::GetUploadProgress() should still work even before the
+// stream is initialized.
+TEST_F(SpdyHttpStreamSpdy2Test, GetUploadProgressBeforeInitialization) {
+ SpdyHttpStream stream(NULL, false);
+ UploadProgress progress = stream.GetUploadProgress();
+ EXPECT_EQ(0u, progress.size());
+ EXPECT_EQ(0u, progress.position());
+}
+
TEST_F(SpdyHttpStreamSpdy2Test, SendRequest) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
diff --git a/net/spdy/spdy_http_stream_spdy3_unittest.cc b/net/spdy/spdy_http_stream_spdy3_unittest.cc
index f9482d6..b14606b 100644
--- a/net/spdy/spdy_http_stream_spdy3_unittest.cc
+++ b/net/spdy/spdy_http_stream_spdy3_unittest.cc
@@ -167,6 +167,15 @@ class SpdyHttpStreamSpdy3Test : public testing::Test {
MockECSignatureCreatorFactory ec_signature_creator_factory_;
};
+// SpdyHttpStream::GetUploadProgress() should still work even before the
+// stream is initialized.
+TEST_F(SpdyHttpStreamSpdy3Test, GetUploadProgressBeforeInitialization) {
+ SpdyHttpStream stream(NULL, false);
+ UploadProgress progress = stream.GetUploadProgress();
+ EXPECT_EQ(0u, progress.size());
+ EXPECT_EQ(0u, progress.position());
+}
+
TEST_F(SpdyHttpStreamSpdy3Test, SendRequest) {
scoped_ptr<SpdyFrame> req(
spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));