efl_ui/scroll_manager: fix int overflow in animation duration calc
authorMike Blumenkrantz <zmike@samsung.com>
Thu, 18 Jul 2019 17:21:26 +0000 (19:21 +0200)
committerSangHyeon Jade Lee <sh10233.lee@samsung.com>
Tue, 23 Jul 2019 05:04:43 +0000 (14:04 +0900)
Summary:
Evas_Coord is a regular int, so this will overflow easily for large
scrollers and return NaN for scroll duration and break the scroll

Reviewers: segfaultxavi

Reviewed By: segfaultxavi

Subscribers: segfaultxavi, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9355

src/lib/elementary/efl_ui_scroll_manager.c

index dd924ed..8379431 100644 (file)
@@ -1232,7 +1232,8 @@ static inline double
 _scroll_manager_animation_duration_get(Evas_Coord dx, Evas_Coord dy)
 {
   double dist = 0.0, vel = 0.0, dur = 0.0;
-  dist = sqrt(dx * dx + dy *dy);
+  uint64_t x = abs(dx), y = abs(dy);
+  dist = sqrt(x * x + y * y);
   vel = _elm_config->thumbscroll_friction_standard / _elm_config->thumbscroll_friction;
   dur = dist / vel;
   dur = (dur > _elm_config->thumbscroll_friction) ? _elm_config->thumbscroll_friction : dur;