[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-bug-tracker] bug#8310: closed (update-game-score -r logic broken

From: GNU bug Tracking System
Subject: [Emacs-bug-tracker] bug#8310: closed (update-game-score -r logic broken with MAX_SCORES)
Date: Wed, 23 Mar 2011 22:07:12 +0000

Your message dated Wed, 23 Mar 2011 15:06:46 -0700
with message-id <address@hidden>
and subject line fix merged to trunk
has caused the GNU bug report #8310,
regarding update-game-score -r logic broken with MAX_SCORES
to be marked as done.

(If you believe you have received this mail in error, please contact

8310: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8310
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: update-game-score -r logic broken with MAX_SCORES Date: Mon, 21 Mar 2011 00:37:09 -0700 User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20110223 Thunderbird/3.1.8
Here's a bug found by gcc -Wstrict-overflow (GCC 4.5.2) this one in
in update-game-score -r.  I plan to install the following patch.

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).
=== modified file 'lib-src/update-game-score.c'
--- lib-src/update-game-score.c 2011-02-21 18:06:25 +0000
+++ lib-src/update-game-score.c 2011-03-21 07:17:22 +0000
@@ -242,13 +242,15 @@
   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. */
+     also increment the beginning of the array, to skip over the
+     *smallest* scores.  Otherwise, just decrementing the number of
+     scores suffices, since the smallest is at the end. */
   if (scorecount > MAX_SCORES)
-    scorecount -= (scorecount - MAX_SCORES);
-  if (reverse)
-    scores += (scorecount - MAX_SCORES);
+    {
+      if (reverse)
+       scores += (scorecount - MAX_SCORES);
+      scorecount = MAX_SCORES;
+    }
   if (write_scores (scorefile, scores, scorecount) < 0)
       unlock_file (scorefile, lockstate);

--- End Message ---
--- Begin Message --- Subject: fix merged to trunk Date: Wed, 23 Mar 2011 15:06:46 -0700 User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9
I committed a fix to the trunk for this,
as part of a recent merge (bzr 103721).

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]