Bug 1171970 - Handle super-long lines in CSS files a bit more gracefully if they cause OOM when creating CSS error messages. r=heycam, a=lmandel
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 05 Jun 2015 23:19:11 -0400
changeset 275370 7a60da0878506978738f89b440f37164343abc4e
parent 275369 0ff16ebaca3caa9a65e8bee33cdef05b4afde4b2
child 275371 ddc45855ad74539d7d5681bcaaf73fce3bce9b3b
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, lmandel
bugs1171970
milestone40.0
Bug 1171970 - Handle super-long lines in CSS files a bit more gracefully if they cause OOM when creating CSS error messages. r=heycam, a=lmandel
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);
   }
 }