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 462208 e1b44c560c28fd2605bbec4f5bfaa7592379a6c9
parent 462207 3b73e8c0c9240d6fe875a1028902ae3a563e0404
child 462209 331456c584bf0156a070ed35a4139b70f2fdfe76
push id41678
push userfelipc@gmail.com
push dateMon, 16 Jan 2017 20:19:38 +0000
reviewersfroydnj, lizzard
bugs1331038
milestone51.0
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