Bug 785753. r=zackw,bzbarsky a=lsblakk
authorMats Palmgren <matspal@gmail.com>
Fri, 31 Aug 2012 02:19:43 +0200
changeset 104641 4a4ec8fa0cf4a1bdcce10b680175a24bf291ff8e
parent 104640 f5b47209610c4e35a7bc6192a5a525b269df15dc
child 104642 4bb760de00bc73a103cd8f61781e3c18cb265bbc
push id1335
push usermpalmgren@mozilla.com
push dateFri, 31 Aug 2012 00:20:34 +0000
treeherdermozilla-beta@4a4ec8fa0cf4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszackw, bzbarsky, lsblakk
bugs785753
milestone16.0
Bug 785753. r=zackw,bzbarsky a=lsblakk
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<PRUint32>(consumed, 0);
       self->mDecoder->Reset();
     }
   } while (consumed < aCount);