(read_scores): Fix corruption of score files.
[bpt/emacs.git] / lib-src / update-game-score.c
index 55737c5..2a699b2 100644 (file)
@@ -357,7 +357,9 @@ read_scores (filename, scores, count)
       scorecount++;
       if (scorecount >= cursize)
        {
-         ret = (struct score_entry *) realloc (ret, cursize *= 2);
+         cursize *= 2;
+         ret = (struct score_entry *)
+           realloc (ret, (sizeof (struct score_entry) * cursize));
          if (!ret)
            return -1;
        }