$OpenBSD$ index a485be4..f28adb4 100644 --- parser/html/nsHtml5Parser.cpp.orig Fri Feb 20 15:40:38 2015 +++ parser/html/nsHtml5Parser.cpp Fri Feb 20 15:40:38 2015 @@ -237,7 +237,8 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer, * WillBuildModel to be called before the document has had its * script global object set. */ - mExecutor->WillBuildModel(eDTDMode_unknown); + rv = mExecutor->WillBuildModel(eDTDMode_unknown); + NS_ENSURE_SUCCESS(rv, rv); } // Return early if the parser has processed EOF @@ -255,7 +256,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer, } mDocumentClosed = true; if (!mBlocked && !mInDocumentWrite) { - ParseUntilBlocked(); + return ParseUntilBlocked(); } return NS_OK; } @@ -378,7 +379,8 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer, if (mTreeBuilder->HasScript()) { mTreeBuilder->Flush(); // Move ops to the executor - mExecutor->FlushDocumentWrite(); // run the ops + rv = mExecutor->FlushDocumentWrite(); // run the ops + NS_ENSURE_SUCCESS(rv, rv); // Flushing tree ops can cause all sorts of things. // Return early if the parser got terminated. if (mExecutor->IsComplete()) { @@ -437,7 +439,8 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer, "Buffer wasn't tokenized to completion?"); // Scripting semantics require a forced tree builder flush here mTreeBuilder->Flush(); // Move ops to the executor - mExecutor->FlushDocumentWrite(); // run the ops + rv = mExecutor->FlushDocumentWrite(); // run the ops + NS_ENSURE_SUCCESS(rv, rv); } else if (stackBuffer.hasMore()) { // The buffer wasn't tokenized to completion. Tokenize the untokenized // content in order to preload stuff. This content will be retokenized @@ -594,11 +597,13 @@ nsHtml5Parser::IsScriptCreated() /* End nsIParser */ // not from interface -void +nsresult nsHtml5Parser::ParseUntilBlocked() { - if (mBlocked || mExecutor->IsComplete() || NS_FAILED(mExecutor->IsBroken())) { - return; + nsresult rv = mExecutor->IsBroken(); + NS_ENSURE_SUCCESS(rv, rv); + if (mBlocked || mExecutor->IsComplete()) { + return NS_OK; } NS_ASSERTION(mExecutor->HasStarted(), "Bad life cycle."); NS_ASSERTION(!mInDocumentWrite, @@ -611,7 +616,7 @@ nsHtml5Parser::ParseUntilBlocked() if (mFirstBuffer == mLastBuffer) { if (mExecutor->IsComplete()) { // something like cache manisfests stopped the parse in mid-flight - return; + return NS_OK; } if (mDocumentClosed) { NS_ASSERTION(!GetStreamParser(), @@ -620,8 +625,10 @@ nsHtml5Parser::ParseUntilBlocked() mTreeBuilder->StreamEnded(); mTreeBuilder->Flush(); mExecutor->FlushDocumentWrite(); + // The below call does memory cleanup, so call it even if the + // parser has been marked as broken. mTokenizer->end(); - return; + return NS_OK; } // never release the last buffer. NS_ASSERTION(!mLastBuffer->getStart() && !mLastBuffer->getEnd(), @@ -643,14 +650,14 @@ nsHtml5Parser::ParseUntilBlocked() NS_ASSERTION(mExecutor->IsInFlushLoop(), "How did we come here without being in the flush loop?"); } - return; // no more data for now but expecting more + return NS_OK; // no more data for now but expecting more } mFirstBuffer = mFirstBuffer->next; continue; } if (mBlocked || mExecutor->IsComplete()) { - return; + return NS_OK; } // now we have a non-empty buffer @@ -667,10 +674,11 @@ nsHtml5Parser::ParseUntilBlocked() } if (mTreeBuilder->HasScript()) { mTreeBuilder->Flush(); - mExecutor->FlushDocumentWrite(); + nsresult rv = mExecutor->FlushDocumentWrite(); + NS_ENSURE_SUCCESS(rv, rv); } if (mBlocked) { - return; + return NS_OK; } } continue;