diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-06-23 09:49:20 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-07-04 11:17:21 -0400 |
commit | 310f8269686b36a4bcc95560246a39e0ecfe4be5 (patch) | |
tree | 7e3ba6a89317bdbee9ff41ad065e998f25cd6975 | |
parent | f6ee844a49e2e40ecb12384242fc34bff21bc3db (diff) | |
download | pango-310f8269686b36a4bcc95560246a39e0ecfe4be5.tar.gz |
Be careful with acos
If the input is outside the [0, 1] range,
acos returns NaN, so clamp to be safe.
-rw-r--r-- | pango/pango-matrix.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/pango/pango-matrix.c b/pango/pango-matrix.c index 78aacae6..3f263101 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.))); } /** |