Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: third_party/agg23/0002-ubsan-error-fixes.patch

Issue 2226023002: Fixup various overflow conditions (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Review cleanup Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/ge/fx_ge_device.cpp ('k') | third_party/agg23/README.pdfium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 diff --git a/third_party/agg23/agg_clip_liang_barsky.h b/third_party/agg23/agg_c lip_liang_barsky.h
2 index db6ca97..5b1261f 100644
3 --- a/third_party/agg23/agg_clip_liang_barsky.h
4 +++ b/third_party/agg23/agg_clip_liang_barsky.h
5 @@ -20,6 +20,7 @@
6 #ifndef AGG_CLIP_LIANG_BARSKY_INCLUDED
7 #define AGG_CLIP_LIANG_BARSKY_INCLUDED
8 #include "agg_basics.h"
9 +#include "third_party/base/numerics/safe_math.h"
10 namespace agg
11 {
12 template<class T>
13 @@ -36,8 +37,18 @@ inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2,
14 T* x, T* y)
15 {
16 const FX_FLOAT nearzero = 1e-30f;
17 - FX_FLOAT deltax = (FX_FLOAT)(x2 - x1);
18 - FX_FLOAT deltay = (FX_FLOAT)(y2 - y1);
19 +
20 + pdfium::base::CheckedNumeric<FX_FLOAT> width = x2;
21 + width -= x1;
22 + if (!width.IsValid())
23 + return 0;
24 + pdfium::base::CheckedNumeric<FX_FLOAT> height = y2;
25 + height -= y1;
26 + if (!height.IsValid())
27 + return 0;
28 +
29 + FX_FLOAT deltax = width.ValueOrDefault(0);
30 + FX_FLOAT deltay = height.ValueOrDefault(0);
31 unsigned np = 0;
32 if(deltax == 0) {
33 deltax = (x1 > clip_box.x1) ? -nearzero : nearzero;
OLDNEW
« no previous file with comments | « core/fxge/ge/fx_ge_device.cpp ('k') | third_party/agg23/README.pdfium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698