summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJUN FANG <jun_fang@foxitsoftware.com>2015-05-13 17:25:40 -0700
committerJUN FANG <jun_fang@foxitsoftware.com>2015-05-13 17:47:48 -0700
commit8b2d91cc207102853fc138cb5d8b11675a26c1a5 (patch)
treed33801bf259e4daaf51e7e18ce817289c9d04198 /core
parent1b8a296b5d1fdd7f6d7daa099f7feef869e05e5e (diff)
downloadpdfium-8b2d91cc207102853fc138cb5d8b11675a26c1a5.tar.xz
Fix integer overflow in conversion from float to integer.
BUG=471991 R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1141613002
Diffstat (limited to 'core')
-rw-r--r--core/src/fxcrt/fx_basic_coords.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/core/src/fxcrt/fx_basic_coords.cpp b/core/src/fxcrt/fx_basic_coords.cpp
index 62061704c7..8e7bb3e751 100644
--- a/core/src/fxcrt/fx_basic_coords.cpp
+++ b/core/src/fxcrt/fx_basic_coords.cpp
@@ -4,6 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <limits.h>
#include "../../include/fxcrt/fx_ext.h"
void FX_RECT::Normalize()
{
@@ -53,15 +54,14 @@ FX_BOOL GetIntersection(FX_FLOAT low1, FX_FLOAT high1, FX_FLOAT low2, FX_FLOAT h
}
extern "C" int FXSYS_round(FX_FLOAT d)
{
- int iRet = 0;
- if (d >= 0.0f) {
- iRet = (int)(d + 0.5f);
- if (iRet >= 0) {
- return iRet;
- }
- return -iRet;
+ if (d < (FX_FLOAT)INT_MIN) {
+ return INT_MIN;
+ }
+ if (d > (FX_FLOAT)INT_MAX) {
+ return INT_MAX;
}
- return (int)(d - 0.5f);
+
+ return (int)round(d);
}
CFX_FloatRect::CFX_FloatRect(const FX_RECT& rect)
{