Bug 1331038 - Make nsPipe handle OOM conditions gracefully. r=froydnj, a=lizzard
authorBen Kelly <ben@wanderview.com>
Fri, 13 Jan 2017 17:11:01 -0800
changeset 353598 02d0ba8567f3de09c9df0a95138d0c4e7b5a57a0
parent 353597 e3c132ec8b1f1843f24fb207e46fdaf626c37aae
child 353599 29164ffa1889e8a8e94c6e61f4c80f8f3c1427f7
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)
reviewersfroydnj, lizzard
bugs1331038
milestone52.0a2
Bug 1331038 - Make nsPipe handle OOM conditions gracefully. r=froydnj, a=lizzard
xpcom/io/nsPipe3.cpp
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -865,17 +865,19 @@ nsPipe::GetWriteSegment(char*& aSegment,
     // being written into the pipe.
     if (IsAdvanceBufferFull(mon)) {
       return NS_BASE_STREAM_WOULD_BLOCK;
     }
 
     // The nsSegmentedBuffer is configured to be "infinite", so this
     // should never return nullptr here.
     char* seg = mBuffer.AppendNewSegment();
-    MOZ_DIAGNOSTIC_ASSERT(seg);
+    if (!seg) {
+      return NS_ERROR_OUT_OF_MEMORY;
+    }
 
     LOG(("OOO appended new segment\n"));
     mWriteCursor = seg;
     mWriteLimit = mWriteCursor + mBuffer.GetSegmentSize();
     ++mWriteSegment;
   }
 
   // make sure read cursor is initialized