Index: pdf/pdfium/pdfium_engine.cc |
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
index f3ae32c109488f52f10438a9ddf030c339d2c431..878ee20a7c325e6ac076a520d5db86af9c4b9ba4 100644 |
--- a/pdf/pdfium/pdfium_engine.cc |
+++ b/pdf/pdfium/pdfium_engine.cc |
@@ -2287,7 +2287,13 @@ int PDFiumEngine::GetMostVisiblePage() { |
if (in_flight_visible_page_) |
return *in_flight_visible_page_; |
+ // We can call GetMostVisiblePage through a callback from PDFium. We have |
+ // to defer the page deletion otherwise we could potentially delete the page |
+ // that originated the calling JS request and destroy the objects that are |
+ // currently being used. |
+ defer_page_unload_ = true; |
CalculateVisiblePages(); |
+ defer_page_unload_ = false; |
return most_visible_page_; |
} |