Bug 1141756 - Part 1: Add null check for mPresShell in nsPrintEngine::GetSeqFrameAndCountPagesInternal. r=dholbert, a=jcristau
authorBob Owen <bobowencode@gmail.com>
Wed, 01 Mar 2017 12:11:58 +0000
changeset 355437 f7c262517722225f5a32979e8939606aa95d8681
parent 355436 eba25396310bf8365f2e26edcdbaf328967461cd
child 355438 420396d5e26de377c222ce81c7b0b152335ba8fa
push id6975
push userryanvm@gmail.com
push dateFri, 24 Mar 2017 21:24:58 +0000
treeherdermozilla-esr52@62df7046e959 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, jcristau
bugs1141756
milestone52.0.2
Bug 1141756 - Part 1: Add null check for mPresShell in nsPrintEngine::GetSeqFrameAndCountPagesInternal. r=dholbert, a=jcristau
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