Commit 4fc47ce2 authored by Tom Sepez's avatar Tom Sepez Committed by Commit Bot

Check FPDF_PageToDevice() return value in FloatPageRectToPixelRect().

The FPDF_PageToDevice() API does not guarantee specific out-parameter
values when failure is indicated, so avoid using them in subsequent
calculations.

Although this can't happen in the currently shipping chrome, future
changes in PDFium to support XFA might make this possible.

Bug: 1141256
Change-Id: Ib0b9b40ab419b2ea698e0dc6172343fea0ef989c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2491978Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819906}
parent 71912995
...@@ -74,13 +74,14 @@ gfx::RectF FloatPageRectToPixelRect(FPDF_PAGE page, const gfx::RectF& input) { ...@@ -74,13 +74,14 @@ gfx::RectF FloatPageRectToPixelRect(FPDF_PAGE page, const gfx::RectF& input) {
int min_y; int min_y;
int max_x; int max_x;
int max_y; int max_y;
FPDF_BOOL ret = FPDF_PageToDevice(page, 0, 0, output_width, output_height, 0, if (!FPDF_PageToDevice(page, 0, 0, output_width, output_height, 0, input.x(),
input.x(), input.y(), &min_x, &min_y); input.y(), &min_x, &min_y)) {
DCHECK(ret); return gfx::RectF();
ret = FPDF_PageToDevice(page, 0, 0, output_width, output_height, 0, }
input.right(), input.bottom(), &max_x, &max_y); if (!FPDF_PageToDevice(page, 0, 0, output_width, output_height, 0,
DCHECK(ret); input.right(), input.bottom(), &max_x, &max_y)) {
return gfx::RectF();
}
if (max_x < min_x) if (max_x < min_x)
std::swap(min_x, max_x); std::swap(min_x, max_x);
if (max_y < min_y) if (max_y < min_y)
......
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