Bug 1141756 - Part 1: Add null check for mPresShell in nsPrintEngine::GetSeqFrameAndCountPagesInternal. r=dholbert, a=lizzard
authorBob Owen <bobowencode@gmail.com>
Wed, 01 Mar 2017 12:11:58 +0000
changeset 378895 d2a1690e80fa92039f0da32fd3d19ce1be6918d0
parent 378894 6ba5938db9d24be0322236bd6ddd63a116f66152
child 378896 c92f80e12f0c6fb8837b6707e75edf4731457b02
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, lizzard
bugs1141756
milestone53.0a2
Bug 1141756 - Part 1: Add null check for mPresShell in nsPrintEngine::GetSeqFrameAndCountPagesInternal. r=dholbert, a=lizzard
layout/printing/nsPrintEngine.cpp
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -326,16 +326,25 @@ nsPrintEngine::InstallPrintPreviewListen
 //----------------------------------------------------------------------
 nsresult 
 nsPrintEngine::GetSeqFrameAndCountPagesInternal(nsPrintObject*  aPO,
                                                 nsIFrame*&    aSeqFrame,
                                                 int32_t&      aCount)
 {
   NS_ENSURE_ARG_POINTER(aPO);
 
+  // This is sometimes incorrectly called before the pres shell has been created
+  // (bug 1141756). MOZ_DIAGNOSTIC_ASSERT so we'll still see the crash in
+  // Nightly/Aurora in case the other patch fixes this.
+  if (!aPO->mPresShell) {
+    MOZ_DIAGNOSTIC_ASSERT(false,
+                          "GetSeqFrameAndCountPages needs a non-null pres shell");
+    return NS_ERROR_FAILURE;
+  }
+
   // Finds the SimplePageSequencer frame
   nsIPageSequenceFrame* seqFrame = aPO->mPresShell->GetPageSequenceFrame();
   aSeqFrame = do_QueryFrame(seqFrame);
   if (!aSeqFrame) {
     return NS_ERROR_FAILURE;
   }
 
   // count the total number of pages