Bug 1312548 - When changing buffer, get the new buffer size too. r=dd, a=ritu
authorDaniel Stenberg <daniel@haxx.se>
Wed, 23 Nov 2016 18:14:07 -0500
changeset 352780 3cde0a94e21bac52f2037f1f93cab1202e8e9f7e
parent 352779 f9e6219c5662390afc4ebfc27445c0b583036607
child 352781 f97d858f6835a36c22aeb846e394bd5044f5494a
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdd, ritu
bugs1312548
milestone52.0a2
Bug 1312548 - When changing buffer, get the new buffer size too. r=dd, a=ritu
netwerk/protocol/http/nsHttpChunkedDecoder.cpp
--- a/netwerk/protocol/http/nsHttpChunkedDecoder.cpp
+++ b/netwerk/protocol/http/nsHttpChunkedDecoder.cpp
@@ -91,24 +91,28 @@ nsHttpChunkedDecoder::ParseChunkRemainin
     NS_PRECONDITION(mChunkRemaining == 0, "chunk remaining should be zero");
     NS_PRECONDITION(count, "unexpected");
 
     *bytesConsumed = 0;
 
     char *p = static_cast<char *>(memchr(buf, '\n', count));
     if (p) {
         *p = 0;
-        if ((p > buf) && (*(p-1) == '\r')) // eliminate a preceding CR
+        count = p - buf; // new length
+        *bytesConsumed = count + 1; // length + newline
+        if ((p > buf) && (*(p-1) == '\r')) { // eliminate a preceding CR
             *(p-1) = 0;
-        *bytesConsumed = p - buf + 1;
+            count--;
+        }
 
         // make buf point to the full line buffer to parse
         if (!mLineBuf.IsEmpty()) {
-            mLineBuf.Append(buf);
+            mLineBuf.Append(buf, count);
             buf = (char *) mLineBuf.get();
+            count = mLineBuf.Length();
         }
 
         if (mWaitEOF) {
             if (*buf) {
                 LOG(("got trailer: %s\n", buf));
                 // allocate a header array for the trailers on demand
                 if (!mTrailers) {
                     mTrailers = new nsHttpHeaderArray();