Bug 1171970. Handle super-long lines in CSS files a bit more gracefully if they cause OOM when creating CSS error messages. r=heycam
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 05 Jun 2015 23:19:11 -0400
changeset 247553 9a757393241c0891f7e13ace1815f7b086c25628
parent 247552 038159ccffe6983e5d3cf90a0b6b8da6c0713bd9
child 247554 910fc75ab5eb7779ea697c7c6de9ce5e2198a313
push id28870
push usercbook@mozilla.com
push dateMon, 08 Jun 2015 09:58:36 +0000
treeherdermozilla-central@4700d1cdf489 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1171970
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
--- a/layout/style/ErrorReporter.cpp
+++ b/layout/style/ErrorReporter.cpp
@@ -238,17 +238,21 @@ ErrorReporter::AddToError(const nsString
   if (mError.IsEmpty()) {
     mError = aErrorText;
     mErrorLineNumber = mScanner->GetLineNumber();
     mErrorColNumber = mScanner->GetColumnNumber();
     // Retrieve the error line once per line, and reuse the same nsString
     // 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 {
     mError.AppendLiteral("  ");
     mError.Append(aErrorText);
   }
 }