# HG changeset patch # User Stefan Monnier # Date 1252696267 0 # Node ID be5f5f7e93cbe7a3c0b44146324306662b6c69c8 # Parent 2a33efb3a1e338bdbae33b196f67265ff6dd16cd (main): Sort scores before trimming them, reported by Jason Feng (bug#4397). diff -r 2a33efb3a1e3 -r be5f5f7e93cb lib-src/ChangeLog --- a/lib-src/ChangeLog Fri Sep 11 18:54:55 2009 +0000 +++ b/lib-src/ChangeLog Fri Sep 11 19:11:07 2009 +0000 @@ -1,3 +1,8 @@ +2009-09-11 Stefan Monnier + + * update-game-score.c (main): Sort scores before trimming them, + reported by Jason Feng (bug#4397). + 2009-09-09 Glenn Morris * Makefile.in ($(DESTDIR)${archlibdir}): Set umask to world-readable diff -r 2a33efb3a1e3 -r be5f5f7e93cb lib-src/update-game-score.c --- a/lib-src/update-game-score.c Fri Sep 11 18:54:55 2009 +0000 +++ b/lib-src/update-game-score.c Fri Sep 11 19:11:07 2009 +0000 @@ -254,15 +254,15 @@ lose_syserr ("Failed to read scores file"); } push_score (&scores, &scorecount, newscore, user_id, newdata); + sort_scores (scores, scorecount, reverse); /* Limit the number of scores. If we're using reverse sorting, then we should increment the beginning of the array, to skip over the *smallest* scores. Otherwise, we just decrement the number of scores, since the smallest will be at the end. */ if (scorecount > MAX_SCORES) scorecount -= (scorecount - MAX_SCORES); - if (reverse) - scores += (scorecount - MAX_SCORES); - sort_scores (scores, scorecount, reverse); + if (reverse) + scores += (scorecount - MAX_SCORES); if (write_scores (scorefile, scores, scorecount) < 0) { unlock_file (scorefile, lockstate);