| diff --git a/third_party/agg23/agg_clip_liang_barsky.h b/third_party/agg23/agg_clip_liang_barsky.h |
| index db6ca97..5b1261f 100644 |
| --- a/third_party/agg23/agg_clip_liang_barsky.h |
| +++ b/third_party/agg23/agg_clip_liang_barsky.h |
| #ifndef AGG_CLIP_LIANG_BARSKY_INCLUDED |
| #define AGG_CLIP_LIANG_BARSKY_INCLUDED |
| +#include "third_party/base/numerics/safe_math.h" |
| @@ -36,8 +37,18 @@ inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2, |
| const float nearzero = 1e-30f; |
| - float deltax = (float)(x2 - x1); |
| - float deltay = (float)(y2 - y1); |
| + pdfium::base::CheckedNumeric<float> width = x2; |
| + pdfium::base::CheckedNumeric<float> height = y2; |
| + float deltax = width.ValueOrDefault(0); |
| + float deltay = height.ValueOrDefault(0); |
| deltax = (x1 > clip_box.x1) ? -nearzero : nearzero; |