Bug 1334081 - prevent null pointer dereference in StreamReaderFunc. r?baku
MozReview-Commit-ID: 4kiFdHrkQmf
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -684,21 +684,21 @@ nsresult
EventSourceImpl::StreamReaderFunc(nsIInputStream* aInputStream,
void* aClosure,
const char* aFromRawSegment,
uint32_t aToOffset,
uint32_t aCount,
uint32_t* aWriteCount)
{
EventSourceImpl* thisObject = static_cast<EventSourceImpl*>(aClosure);
- thisObject->AssertIsOnTargetThread();
if (!thisObject || !aWriteCount) {
NS_WARNING("EventSource cannot read from stream: no aClosure or aWriteCount");
return NS_ERROR_FAILURE;
}
+ thisObject->AssertIsOnTargetThread();
thisObject->ParseSegment((const char*)aFromRawSegment, aCount);
*aWriteCount = aCount;
return NS_OK;
}
void
EventSourceImpl::ParseSegment(const char* aBuffer, uint32_t aLength)
{