0

Move some checks to PDFiumEngine::AppendPage()

Make PDFiumEngine::AppendPage() check its input parameters, instead of
the caller. Change these DCHECKs into CHECKs, per modern coding
guidance, since they are cheap to run. This also helps to catch a rare
crash where it looks as though the impossible has happened.

Bug: 1488743
Change-Id: Ia491b20b771beebc0cd968908873228793e86698
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4903239
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1204952}
This commit is contained in:
Lei Zhang
2023-10-04 00:21:31 +00:00
committed by Chromium LUCI CQ
parent 1858874765
commit bfa2b131cf
2 changed files with 3 additions and 2 deletions

@ -2307,9 +2307,7 @@ void PdfViewWebPlugin::PreviewDocumentLoadComplete() {
preview_document_load_state_ = DocumentLoadState::kComplete;
int dest_page_index = preview_pages_info_.front().dest_page_index;
DCHECK_GT(dest_page_index, 0);
preview_pages_info_.pop();
DCHECK(preview_engine_);
engine_->AppendPage(preview_engine_.get(), dest_page_index);
++print_preview_loaded_page_count_;

@ -759,6 +759,9 @@ std::unique_ptr<URLLoaderWrapper> PDFiumEngine::CreateURLLoader() {
}
void PDFiumEngine::AppendPage(PDFEngine* engine, int index) {
CHECK(engine);
CHECK(PageIndexInBounds(index));
// Unload and delete the blank page before appending.
pages_[index]->Unload();
pages_[index]->set_calculated_links(false);