[pango/pango2] Be careful with acos



commit 2194a8c2c4dbbaed6baf86255c27a15e935bb747
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 23 09:49:20 2022 -0400

    Be careful with acos
    
    If the input is outside the [0, 1] range,
    acos returns NaN, so clamp to be safe.

 pango/pango-matrix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/pango/pango-matrix.c b/pango/pango-matrix.c
index 78aacae6d..4fb3d1308 100644
--- a/pango/pango-matrix.c
+++ b/pango/pango-matrix.c
@@ -269,7 +269,7 @@ pango_matrix_get_rotation (const PangoMatrix *matrix)
 
   pango_matrix_transform_distance (matrix, &x, &y);
 
-  return RAD_TO_DEG (acos (x /  sqrtf (x*x + y*y)));
+  return RAD_TO_DEG (acos (CLAMP (0., 1., x /  sqrtf (x*x + y*y))));
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]