0002-ubsan-error-fixes.patch revision 4d3acf4ec42bf6e838f9060103aff98fbf170794
1diff --git a/third_party/agg23/agg_clip_liang_barsky.h b/third_party/agg23/agg_clip_liang_barsky.h 2index 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; 34