Commit 744e9971 authored by Tom Sepez's avatar Tom Sepez Committed by Chromium LUCI CQ

Check still more return codes from FPDF_ functions.

There are a few more spots similar to
  https://chromium-review.googlesource.com/c/chromium/src/+/2628044

Either check the return code, or pre-initialize the out parameters
so that uninitialized reads are avoided should false someday be
returned.

-- tidy one multiple-assignment encountered while looking for
   other occurences.

Bug: 1166478,1166462
Change-Id: I2aef090f87aac0cd393e977809c8a24eb8d36de8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2630735Reviewed-by: default avatarK. Moon <kmoon@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843842}
parent 380d00c1
......@@ -1085,8 +1085,8 @@ PP_PrivateAccessibilityFocusInfo PDFiumEngine::GetFocusInfo() {
break;
}
case FocusElementType::kPage: {
int page_index;
FPDF_ANNOTATION focused_annot;
int page_index = -1;
FPDF_ANNOTATION focused_annot = nullptr;
FPDF_BOOL ret = FORM_GetFocusedAnnot(form(), &page_index, &focused_annot);
DCHECK(ret);
......@@ -3573,7 +3573,8 @@ void PDFiumEngine::DeviceToPage(int page_index,
const gfx::Point& device_point,
double* page_x,
double* page_y) {
*page_x = *page_y = 0;
*page_x = 0;
*page_y = 0;
float device_x = device_point.x();
float device_y = device_point.y();
int temp_x = static_cast<int>((device_x + position_.x()) / current_zoom_ -
......
......@@ -749,14 +749,15 @@ PDFiumPage::Area PDFiumPage::GetCharIndex(const gfx::Point& point,
LinkTarget* target) {
if (!available_)
return NONSELECTABLE_AREA;
gfx::Point device_point = point - rect_.OffsetFromOrigin();
double new_x;
double new_y;
FPDF_BOOL ret =
FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(),
ToPDFiumRotation(orientation), device_point.x(),
device_point.y(), &new_x, &new_y);
DCHECK(ret);
if (!FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(),
ToPDFiumRotation(orientation), device_point.x(),
device_point.y(), &new_x, &new_y)) {
return NONSELECTABLE_AREA;
}
// hit detection tolerance, in points.
constexpr double kTolerance = 20.0;
......@@ -992,7 +993,8 @@ void PDFiumPage::PopulateWebLinks() {
double top;
double right;
double bottom;
FPDFLink_GetRect(links.get(), i, j, &left, &top, &right, &bottom);
if (!FPDFLink_GetRect(links.get(), i, j, &left, &top, &right, &bottom))
continue;
gfx::Rect rect = PageToScreen(gfx::Point(), 1.0, left, top, right, bottom,
PageOrientation::kOriginal);
if (rect.IsEmpty())
......@@ -1075,9 +1077,9 @@ void PDFiumPage::CalculateImages() {
float top;
float right;
float bottom;
FPDF_BOOL ret =
FPDFPageObj_GetBounds(page_object, &left, &bottom, &right, &top);
DCHECK(ret);
if (!FPDFPageObj_GetBounds(page_object, &left, &bottom, &right, &top))
continue;
Image image;
image.bounding_rect = PageToScreen(gfx::Point(), 1.0, left, top, right,
bottom, PageOrientation::kOriginal);
......
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