Commit b0a27cb1de815e10957ce36395af4e55e8a754ab

Simon McVittie 2022-05-19T19:45:24

Avoid unintended float -> double conversion in SDL_FRectEqualsEpsilon Resolves: https://github.com/libsdl-org/SDL/issues/5691 Signed-off-by: Simon McVittie <smcv@collabora.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/include/SDL_rect.h b/include/SDL_rect.h
index b678c7a..6c641c5 100644
--- a/include/SDL_rect.h
+++ b/include/SDL_rect.h
@@ -252,10 +252,10 @@ SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
 SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon(const SDL_FRect *a, const SDL_FRect *b, const float epsilon)
 {
     return (a && b && ((a == b) ||
-            ((SDL_fabs(a->x - b->x) <= epsilon) &&
-            (SDL_fabs(a->y - b->y) <= epsilon) &&
-            (SDL_fabs(a->w - b->w) <= epsilon) &&
-            (SDL_fabs(a->h - b->h) <= epsilon))))
+            ((SDL_fabsf(a->x - b->x) <= epsilon) &&
+            (SDL_fabsf(a->y - b->y) <= epsilon) &&
+            (SDL_fabsf(a->w - b->w) <= epsilon) &&
+            (SDL_fabsf(a->h - b->h) <= epsilon))))
             ? SDL_TRUE : SDL_FALSE;
 }