Bug 631967 - Fix unsafe pointer dereference. r=mayhemer
authorEvan Shaw <edsrzf@gmail.com>
Thu, 21 Jul 2011 22:29:00 -0400
changeset 73714 9dda487bc910f09a638dbc688fc49c03cceb4dc0
parent 73713 0f4acd33ac43fee82acbd6ea83275c22e921c2a5
child 73715 6ea906365d1fb0a26b9fa82453e1f039b2a92b49
push id20911
push usermak77@bonardo.net
push dateWed, 03 Aug 2011 08:47:10 +0000
treeherdermozilla-central@c35c69e1ce99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs631967
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 631967 - Fix unsafe pointer dereference. r=mayhemer
netwerk/protocol/http/HttpBaseChannel.cpp
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -1290,30 +1290,30 @@ NS_IMETHODIMP
 HttpBaseChannel::GetEntityID(nsACString& aEntityID)
 {
   // Don't return an entity ID for Non-GET requests which require
   // additional data
   if (mRequestHead.Method() != nsHttp::Get) {
     return NS_ERROR_NOT_RESUMABLE;
   }
 
-  // Don't return an entity if the server sent the following header:
-  // Accept-Ranges: none
-  // Not sending the Accept-Ranges header means we can still try
-  // sending range requests.
-  const char* acceptRanges =
-      mResponseHead->PeekHeader(nsHttp::Accept_Ranges);
-  if (acceptRanges &&
-      !nsHttp::FindToken(acceptRanges, "bytes", HTTP_HEADER_VALUE_SEPS)) {
-    return NS_ERROR_NOT_RESUMABLE;
-  }
-
   PRUint64 size = LL_MAXUINT;
   nsCAutoString etag, lastmod;
   if (mResponseHead) {
+    // Don't return an entity if the server sent the following header:
+    // Accept-Ranges: none
+    // Not sending the Accept-Ranges header means we can still try
+    // sending range requests.
+    const char* acceptRanges =
+        mResponseHead->PeekHeader(nsHttp::Accept_Ranges);
+    if (acceptRanges &&
+        !nsHttp::FindToken(acceptRanges, "bytes", HTTP_HEADER_VALUE_SEPS)) {
+      return NS_ERROR_NOT_RESUMABLE;
+    }
+
     size = mResponseHead->TotalEntitySize();
     const char* cLastMod = mResponseHead->PeekHeader(nsHttp::Last_Modified);
     if (cLastMod)
       lastmod = cLastMod;
     const char* cEtag = mResponseHead->PeekHeader(nsHttp::ETag);
     if (cEtag)
       etag = cEtag;
   }