Bug 785753. r=zackw,bzbarsky
authorMats Palmgren <matspal@gmail.com>
Thu, 30 Aug 2012 03:34:53 +0200
changeset 103853 5e5d1e9a4a7647d6913aeee3fec215bf148cb1e1
parent 103852 5e11ebbe23419f72923704916d3f7a6cd570dd50
child 103854 856299bce84fdd307f321615e0cb6dd58916fe24
push id14200
push usermpalmgren@mozilla.com
push dateThu, 30 Aug 2012 01:34:53 +0000
treeherdermozilla-inbound@5e5d1e9a4a76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszackw, bzbarsky
bugs785753
milestone18.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 785753. r=zackw,bzbarsky
netwerk/base/src/nsUnicharStreamLoader.cpp
--- a/netwerk/base/src/nsUnicharStreamLoader.cpp
+++ b/netwerk/base/src/nsUnicharStreamLoader.cpp
@@ -215,19 +215,22 @@ nsUnicharStreamLoader::WriteSegmentFun(n
                                  self->mBuffer.BeginWriting() + haveRead,
                                  &dstLen);
     haveRead += dstLen;
     // XXX if srcLen is negative, we want to drop the _first_ byte in
     // the erroneous byte sequence and try again.  This is not quite
     // possible right now -- see bug 160784
     consumed += srcLen;
     if (NS_FAILED(rv)) {
-      NS_ASSERTION(0 < capacity - haveRead,
-                   "Decoder returned an error but filled the output buffer! "
-                   "Should not happen.");
+      if (haveRead >= capacity) {
+        // Make room for writing the 0xFFFD below (bug 785753).
+        if (!self->mBuffer.SetCapacity(haveRead + 1, fallible_t())) {
+          return NS_ERROR_OUT_OF_MEMORY;
+        }
+      }
       self->mBuffer.BeginWriting()[haveRead++] = 0xFFFD;
       ++consumed;
       // XXX this is needed to make sure we don't underrun our buffer;
       // bug 160784 again
       consumed = NS_MAX<uint32_t>(consumed, 0);
       self->mDecoder->Reset();
     }
   } while (consumed < aCount);