summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-02-10 22:39:05 +0000
committerMoonchild <moonchild@palemoon.org>2022-02-10 22:39:05 +0000
commit273c210f90d4ad01719bb67e140d85927efd8c54 (patch)
treeef62ab8e27085fb131c98ebd57d04fc7e899bc82 /components
parentf19cbb3f9e06e08a09dc4107ba0f6d3eea267d30 (diff)
downloadaura-central-273c210f90d4ad01719bb67e140d85927efd8c54.tar.gz
[htmlfive] Improve parser sanity checks.
Diffstat (limited to 'components')
-rw-r--r--components/htmlfive/nsHtml5StreamParser.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/components/htmlfive/nsHtml5StreamParser.cpp b/components/htmlfive/nsHtml5StreamParser.cpp
index 4421fa99b..9779aa194 100644
--- a/components/htmlfive/nsHtml5StreamParser.cpp
+++ b/components/htmlfive/nsHtml5StreamParser.cpp
@@ -1155,14 +1155,14 @@ nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
uint32_t aLength)
{
nsresult rv;
- if (NS_FAILED(rv = mExecutor->IsBroken())) {
- return rv;
- }
NS_ASSERTION(mRequest == aRequest, "Got data on wrong stream.");
uint32_t totalRead;
// Main thread to parser thread dispatch requires copying to buffer first.
if (NS_IsMainThread()) {
+ if (NS_FAILED(rv = mExecutor->IsBroken())) {
+ return rv;
+ }
auto data = MakeUniqueFallible<uint8_t[]>(aLength);
if (!data) {
return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
@@ -1183,6 +1183,9 @@ nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
NS_ASSERTION(IsParserThread(), "Wrong thread!");
mozilla::MutexAutoLock autoLock(mTokenizerMutex);
+ if (NS_FAILED(rv = mTreeBuilder->IsBroken())) {
+ return rv;
+ }
// Read directly from response buffer.
rv = aInStream->ReadSegments(CopySegmentsToParser, this, aLength,
&totalRead);
@@ -1194,6 +1197,7 @@ nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
}
}
+// Called under lock by function ptr
/* static */ nsresult
nsHtml5StreamParser::CopySegmentsToParser(nsIInputStream *aInStream,
void *aClosure,