Bug 1082114 - Fix pre-setData() calls to .available(), r=Waldo
authorSteve Fink <sfink@mozilla.com>
Mon, 13 Oct 2014 13:42:44 -0700
changeset 210231 4030d1c94b175cf15a98691d45943a420207d1ec
parent 210230 bc585ed304a47ba9d2f5b3a31fca6bc224c5348c
child 210232 32fae63479051c3b1206c5136a990edfbeb59c48
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersWaldo
bugs1082114
milestone35.0a1
Bug 1082114 - Fix pre-setData() calls to .available(), r=Waldo
netwerk/base/src/ArrayBufferInputStream.cpp
--- a/netwerk/base/src/ArrayBufferInputStream.cpp
+++ b/netwerk/base/src/ArrayBufferInputStream.cpp
@@ -49,18 +49,22 @@ ArrayBufferInputStream::Close()
 }
 
 NS_IMETHODIMP
 ArrayBufferInputStream::Available(uint64_t* aCount)
 {
   if (mClosed) {
     return NS_BASE_STREAM_CLOSED;
   }
-  uint32_t buflen = JS_GetArrayBufferByteLength(mArrayBuffer->get());
-  *aCount = buflen ? buflen - mPos : 0;
+  if (mArrayBuffer) {
+    uint32_t buflen = JS_GetArrayBufferByteLength(mArrayBuffer->get());
+    *aCount = buflen ? buflen - mPos : 0;
+  } else {
+    *aCount = 0;
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ArrayBufferInputStream::Read(char* aBuf, uint32_t aCount, uint32_t *aReadCount)
 {
   return ReadSegments(NS_CopySegmentToBuffer, aBuf, aCount, aReadCount);
 }