[pango/pango2: 1/2] Be careful with acos
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 1/2] Be careful with acos
- Date: Fri, 24 Jun 2022 01:45:41 +0000 (UTC)
commit e54946ed6c1bc2cf5b04f8cb37bb863a7a2451fc
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..3f263101d 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 (x / sqrtf (x*x + y*y), -1., 1.)));
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]