summaryrefslogtreecommitdiff
path: root/core/src
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:25:40 -0700
commit08e021c81a41c5394a045b8e71b08bf0fb62634c (patch)
tree6873f52ca8762dfb0d3b8a759a5e8046a13155e4 /core/src
parent9857e204304e21685a10e98037dd05cb10ab9bf5 (diff)
downloadpdfium-08e021c81a41c5394a045b8e71b08bf0fb62634c.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/src')
-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)
{