mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-03 22:07:30 +09:00
[htmlfive] Improve parser sanity checks.
This commit is contained in:
parent
b924810a3e
commit
b74a23aee3
1 changed files with 7 additions and 3 deletions
|
|
@ -1155,14 +1155,14 @@ nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
|
||||||
uint32_t aLength)
|
uint32_t aLength)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (NS_FAILED(rv = mExecutor->IsBroken())) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ASSERTION(mRequest == aRequest, "Got data on wrong stream.");
|
NS_ASSERTION(mRequest == aRequest, "Got data on wrong stream.");
|
||||||
uint32_t totalRead;
|
uint32_t totalRead;
|
||||||
// Main thread to parser thread dispatch requires copying to buffer first.
|
// Main thread to parser thread dispatch requires copying to buffer first.
|
||||||
if (NS_IsMainThread()) {
|
if (NS_IsMainThread()) {
|
||||||
|
if (NS_FAILED(rv = mExecutor->IsBroken())) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
auto data = MakeUniqueFallible<uint8_t[]>(aLength);
|
auto data = MakeUniqueFallible<uint8_t[]>(aLength);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
|
return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
@ -1183,6 +1183,9 @@ nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
|
||||||
NS_ASSERTION(IsParserThread(), "Wrong thread!");
|
NS_ASSERTION(IsParserThread(), "Wrong thread!");
|
||||||
mozilla::MutexAutoLock autoLock(mTokenizerMutex);
|
mozilla::MutexAutoLock autoLock(mTokenizerMutex);
|
||||||
|
|
||||||
|
if (NS_FAILED(rv = mTreeBuilder->IsBroken())) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
// Read directly from response buffer.
|
// Read directly from response buffer.
|
||||||
rv = aInStream->ReadSegments(CopySegmentsToParser, this, aLength,
|
rv = aInStream->ReadSegments(CopySegmentsToParser, this, aLength,
|
||||||
&totalRead);
|
&totalRead);
|
||||||
|
|
@ -1194,6 +1197,7 @@ nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called under lock by function ptr
|
||||||
/* static */ nsresult
|
/* static */ nsresult
|
||||||
nsHtml5StreamParser::CopySegmentsToParser(nsIInputStream *aInStream,
|
nsHtml5StreamParser::CopySegmentsToParser(nsIInputStream *aInStream,
|
||||||
void *aClosure,
|
void *aClosure,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue