Bug 1082114 - Fix pre-setData() calls to .available(). r=Waldo, a=sledru
authorSteve Fink <sfink@mozilla.com>
Mon, 13 Oct 2014 13:42:44 -0700
changeset 223454 a06058806b8bf998c3f3a132a8105cfcda0866b9
parent 223453 735ab4890a4a3f28e163e59b0051722140671644
child 223455 fc795bf846a720719b3396b966d00eed5ceeb36a
push id5
push usergszorc@mozilla.com
push dateWed, 29 Oct 2014 02:51:31 +0000
reviewersWaldo, sledru
bugs1082114
milestone35.0a2
Bug 1082114 - Fix pre-setData() calls to .available(). r=Waldo, a=sledru
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);
 }