aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert2011-03-21 00:46:53 -0700
committerPaul Eggert2011-03-21 00:46:53 -0700
commitf0d80d43baa89029ea030a98350a74793ee5dc89 (patch)
tree392ccea9f3a58959e20817b046ecc25dceb3a878 /lib-src
parent37dd57d1e53ffb2d9dee6cc66d807e6d2575ef57 (diff)
downloademacs-f0d80d43baa89029ea030a98350a74793ee5dc89.tar.gz
emacs-f0d80d43baa89029ea030a98350a74793ee5dc89.zip
update-game-score: fix bug with -r
* update-game-score.c (main): Don't set 'scores' to garbage when -r is specified and scorecount != MAX_SCORES. This bug was introduced in the 2002-04-10 change, and was found with gcc -Wstrict-overflow (GCC 4.5.2, x86-64).
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog6
-rw-r--r--lib-src/update-game-score.c14
2 files changed, 14 insertions, 6 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index cc713f0b68c..2548561f313 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,5 +1,11 @@
12011-03-21 Paul Eggert <eggert@cs.ucla.edu> 12011-03-21 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 update-game-score: fix bug with -r
4 * update-game-score.c (main): Don't set 'scores' to garbage when
5 -r is specified and scorecount != MAX_SCORES. This bug was
6 introduced in the 2002-04-10 change, and was found with gcc
7 -Wstrict-overflow (GCC 4.5.2, x86-64).
8
3 fakemail: Remove dependency on ignore-value. 9 fakemail: Remove dependency on ignore-value.
4 This undoes some of the recent fakemail-related changes. 10 This undoes some of the recent fakemail-related changes.
5 It is made possible due to recent changes to gnulib's stdio module. 11 It is made possible due to recent changes to gnulib's stdio module.
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c
index 70b79a64f91..e95e2ce259d 100644
--- a/lib-src/update-game-score.c
+++ b/lib-src/update-game-score.c
@@ -242,13 +242,15 @@ main (int argc, char **argv)
242 push_score (&scores, &scorecount, newscore, user_id, newdata); 242 push_score (&scores, &scorecount, newscore, user_id, newdata);
243 sort_scores (scores, scorecount, reverse); 243 sort_scores (scores, scorecount, reverse);
244 /* Limit the number of scores. If we're using reverse sorting, then 244 /* Limit the number of scores. If we're using reverse sorting, then
245 we should increment the beginning of the array, to skip over the 245 also increment the beginning of the array, to skip over the
246 *smallest* scores. Otherwise, we just decrement the number of 246 *smallest* scores. Otherwise, just decrementing the number of
247 scores, since the smallest will be at the end. */ 247 scores suffices, since the smallest is at the end. */
248 if (scorecount > MAX_SCORES) 248 if (scorecount > MAX_SCORES)
249 scorecount -= (scorecount - MAX_SCORES); 249 {
250 if (reverse) 250 if (reverse)
251 scores += (scorecount - MAX_SCORES); 251 scores += (scorecount - MAX_SCORES);
252 scorecount = MAX_SCORES;
253 }
252 if (write_scores (scorefile, scores, scorecount) < 0) 254 if (write_scores (scorefile, scores, scorecount) < 0)
253 { 255 {
254 unlock_file (scorefile, lockstate); 256 unlock_file (scorefile, lockstate);