diff options
author | dsinclair <dsinclair@chromium.org> | 2016-08-09 06:50:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-09 06:50:28 -0700 |
commit | fb362089d952950212ccf159f86a46923f223172 (patch) | |
tree | 23692bebb1dc91a8b2998663336ec7902f540845 /core/fxcrt | |
parent | 5d8e5aa882fe8d37d32b71137f039165581ddb82 (diff) | |
download | pdfium-fb362089d952950212ccf159f86a46923f223172.tar.xz |
Fixup various overflow conditions
There were several overflows detected by the PDF from the linked bug. This
Cl fixes up the base causes of each of them.
BUG=chromium:635473
Review-Url: https://codereview.chromium.org/2226023002
Diffstat (limited to 'core/fxcrt')
-rw-r--r-- | core/fxcrt/include/fx_coordinates.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/fxcrt/include/fx_coordinates.h b/core/fxcrt/include/fx_coordinates.h index eff2a7258a..ce97f6f6f3 100644 --- a/core/fxcrt/include/fx_coordinates.h +++ b/core/fxcrt/include/fx_coordinates.h @@ -150,6 +150,14 @@ struct FX_RECT { int Height() const { return bottom - top; } bool IsEmpty() const { return right <= left || bottom <= top; } + bool Valid() const { + pdfium::base::CheckedNumeric<int> w = right; + pdfium::base::CheckedNumeric<int> h = bottom; + w -= left; + h -= top; + return w.IsValid() && h.IsValid(); + } + void Normalize(); void Intersect(const FX_RECT& src); |