Commit 7b585bae authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1789439 - Don't allow reentrant programmatic print calls. r=smaug,peterv a=pascalc

parent 913a8d68
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -5132,14 +5132,17 @@ void nsGlobalWindowOuter::PrintOuter(ErrorResult& aError) {
#ifdef NS_PRINTING
  RefPtr<BrowsingContext> top =
      mBrowsingContext ? mBrowsingContext->Top() : nullptr;
  bool oldIsPrinting = top && top->GetIsPrinting();
  if (NS_WARN_IF(top && top->GetIsPrinting())) {
    return;
  }

  if (top) {
    Unused << top->SetIsPrinting(true);
  }

  auto unset = MakeScopeExit([&] {
    if (top) {
      Unused << top->SetIsPrinting(oldIsPrinting);
      Unused << top->SetIsPrinting(false);
    }
  });