0
Files
src/pdf
Lei Zhang ac8c360346 [PDF] Fix crash when double clicking at the end of a page
Double-click text selection at the end of a page is a literal edge case
that PDFiumEngine::OnMultipleClick() does not handle correctly. This
method creates a PDFiumRange where the character index is out of bounds.
In older code, this would have triggered a DCHECK() failure, but not
crash when DCHECKs are turned off. After https://crrev.com/1417508, the
DCHECK() failure still happens. When DCHECKs are turned off, code
execution eventually triggers a crash, because that CL assumed the
character index is never out of bounds.

Add a test case that triggers this crash, and fix the crash by
calculating the character index correctly in OnMultipleClick().

Additionally:

1) Add another test case for double clicking on a blank page, to help
   provide more test coverage, and to show OnMultipleClick() does not
   need to handle pages with no text.
2) Upgrade a cheap DCHECK_GE() to CHECK_GE().

Bug: 401992988
Change-Id: I60e1a4afb7cbb956205ce8f304b15701cf762ce7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6347717
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1431938}
2025-03-12 23:23:28 -07:00
..

//pdf contains the PDF plugin, its Blink-based replacement, as well as PDF utility functions that leverage PDFium. It can use low-level components that live below the content layer, as well as other foundational code like //printing. It should not use //content or anything in //components that lives above the content layer. Code that lives above the content layer should live in //components/pdf, or in the embedder. All the code here should run in sandboxed child processes.

TODO(crbug.com/40186598): Remove existing //content dependencies.