Commit b1d5c8d4 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Handle out of bound indices in PDFiumPage::GetTextRunInfo().

Check to see if the |char_index| is within bounds, and return early if
it is. Otherwise, the code internal to PDFiumPage, which only works with
valid indices, will behave badly.

Bug: 996629
Change-Id: I71c27b1039e6d997d3ce5613e8df7a30882e8347
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1767606
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#690041}
parent b653d5ef
......@@ -255,12 +255,25 @@ void PDFiumPage::GetTextRunInfo(int start_char_index,
uint32_t* out_len,
double* out_font_size,
pp::FloatRect* out_bounds) {
if (start_char_index < 0) {
*out_len = 0;
*out_font_size = 0;
*out_bounds = pp::FloatRect();
return;
}
FPDF_PAGE page = GetPage();
FPDF_TEXTPAGE text_page = GetTextPage();
int chars_count = FPDFText_CountChars(text_page);
int char_index = GetFirstNonUnicodeWhiteSpaceCharIndex(
text_page, start_char_index, chars_count);
if (char_index >= chars_count) {
*out_len = 0;
*out_font_size = 0;
*out_bounds = pp::FloatRect();
return;
}
pp::FloatRect start_char_rect =
GetFloatCharRectInPixels(page, text_page, char_index);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment