Bug 1566482 - Properly calculate end in SetHttpTrailers. r=dragana
authorChristian Holler <choller@mozilla.com>
Wed, 31 Jul 2019 07:53:17 +0000
changeset 485605 6c522d98565a3b9829be1e79c0a9fc5cdd777cd9
parent 485604 0b6196b052f177e19eb22c32df9102167397c196
child 485606 f2c7c870b1207f3ee4cf48e117276fac5f555bc6
push id91349
push usercholler@mozilla.com
push dateWed, 31 Jul 2019 15:31:54 +0000
treeherderautoland@6c522d98565a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1566482
milestone70.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 1566482 - Properly calculate end in SetHttpTrailers. r=dragana Differential Revision: https://phabricator.services.mozilla.com/D38272
netwerk/protocol/http/nsHttpTransaction.cpp
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -2358,17 +2358,18 @@ void nsHttpTransaction::SetHttpTrailers(
   int32_t cur = 0;
   int32_t len = aTrailers.Length();
   while (cur < len) {
     int32_t newline = aTrailers.FindCharInSet("\n", cur);
     if (newline == -1) {
       newline = len;
     }
 
-    int32_t end = aTrailers[newline - 1] == '\r' ? newline - 1 : newline;
+    int32_t end =
+        (newline && aTrailers[newline - 1] == '\r') ? newline - 1 : newline;
     nsDependentCSubstring line(aTrailers, cur, end);
     nsHttpAtom hdr = {nullptr};
     nsAutoCString hdrNameOriginal;
     nsAutoCString val;
     if (NS_SUCCEEDED(mForTakeResponseTrailers->ParseHeaderLine(
             line, &hdr, &hdrNameOriginal, &val))) {
       if (hdr == nsHttp::Server_Timing) {
         Unused << mForTakeResponseTrailers->SetHeaderFromNet(