From 4056495adb5b724058e586d4cb54ba9f84a9ee09 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 5 Jun 2015 23:19:11 -0400 Subject: [PATCH] Bug 1171970. Handle super-long lines in CSS files a bit more gracefully if they cause OOM when creating CSS error messages. r=heycam --- layout/style/ErrorReporter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/layout/style/ErrorReporter.cpp b/layout/style/ErrorReporter.cpp index f52550fb065..81d0b0740c2 100644 --- a/layout/style/ErrorReporter.cpp +++ b/layout/style/ErrorReporter.cpp @@ -243,7 +243,11 @@ ErrorReporter::AddToError(const nsString &aErrorText) // for all errors on that line. That causes the text of the line to // be shared among all the nsIScriptError objects. if (mErrorLine.IsEmpty() || mErrorLineNumber != mPrevErrorLineNumber) { - mErrorLine = mScanner->GetCurrentLine(); + // Be careful here: the error line might be really long and OOM + // when we try to make a copy here. If so, just leave it empty. + if (!mErrorLine.Assign(mScanner->GetCurrentLine(), fallible)) { + mErrorLine.Truncate(); + } mPrevErrorLineNumber = mErrorLineNumber; } } else {