From f536db2b714c98961172e9351a99c1b527c4294d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 23 Nov 2016 18:42:27 +0200 Subject: [PATCH] ges-timeline: Properly calculate absolute diff of two unsigned integers CID 1394491. --- ges/ges-timeline.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index 6079077c20..6f069e3099 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -1300,14 +1300,20 @@ ges_timeline_snap_position (GESTimeline * timeline, GESTrackElement *tmp_trackelement = g_hash_table_lookup (priv->by_object, iter_tc); GESContainer *tmp_container = get_toplevel_container (tmp_trackelement); + GstClockTimeDiff diff; if (tmp_container == container) continue; - if (ABS (timecode - *iter_tc) > smallest_offset) + if (timecode > *iter_tc) + diff = timecode - *iter_tc; + else + diff = *iter_tc - timecode; + + if (diff > smallest_offset) break; - smallest_offset = ABS (timecode - *iter_tc); + smallest_offset = diff; ret = iter_tc; }