From: <al...@us...> - 2024-01-21 12:48:44
|
This is an automated email from the git hooks/post-receive-user script. allura pushed a commit to branch master in repository fuse. View the commit online: https://sourceforge.net/p/fuse-emulator/fuse/ci/54bb53145a42f054dd7b5e5aa0bfa2d41020e265/ The following commit(s) were added to refs/heads/master by this push: new 54bb5314 Bug 504 - avoid overflow in event_add_cmp 54bb5314 is described below commit 54bb53145a42f054dd7b5e5aa0bfa2d41020e265 Author: Pete Moore <pm...@mo...> AuthorDate: Sat Jan 20 11:16:04 2024 +0100 Bug 504 - avoid overflow in event_add_cmp --- event.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/event.c b/event.c index cd0fc245..ce90b343 100644 --- a/event.c +++ b/event.c @@ -84,8 +84,13 @@ static gint event_add_cmp( gconstpointer a1, gconstpointer b1 ) { const event_t *a = a1, *b = b1; - - return a->tstates != b->tstates ? a->tstates - b->tstates + /* (a->tstates - b->tstates) although usually sufficient as a GCompareFunc, + can overflow for high values of b->tstates. High values can occur in e.g. + timer events when fuse is run with --speed <very high number>. This + overflow can cause a crash if it pushes a spectrum frame event beyond a + distant timer event. Therefore use overflow safe variation + (a->tstates > b->tstates) - (a->tstates < b->tstates) instead. */ + return a->tstates != b->tstates ? (a->tstates > b->tstates) - (a->tstates < b->tstates) : a->type - b->type; } |