Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2004:
[Freeciv-Dev] (PR#9037) memory leak in score reporting
Home

[Freeciv-Dev] (PR#9037) memory leak in score reporting

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9037) memory leak in score reporting
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 19 Jun 2004 17:48:48 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9037 >

==2658== 632 bytes in 64 blocks are definitely lost in loss record 14 of 20
==2658==    at 0x3C01F40D: malloc (vg_replace_malloc.c:105)
==2658==    by 0x804D655: fc_real_malloc (mem.c:58)
==2658==    by 0x808CE56: report_final_scores (report.c:1119)
==2658==    by 0x804F233: srv_main (srv_main.c:1524)
==2658==    by 0x804A3CC: main (civserver.c:161)


An array is allocated but never freed.  Most likely the free call was 
removed recently, I guess.  Anyway we may as well use a variable-sized 
array here.

jason

Index: server/report.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/report.c,v
retrieving revision 1.50
diff -u -r1.50 report.c
--- server/report.c     11 May 2004 17:59:34 -0000      1.50
+++ server/report.c     20 Jun 2004 00:47:12 -0000
@@ -1116,8 +1116,7 @@
 void report_final_scores(void)
 {
   int i, j = 0;
-  struct player_score_entry *size =
-      fc_malloc(sizeof(struct player_score_entry) * game.nplayers);
+  struct player_score_entry size[game.nplayers];
   struct packet_endgame_report packet;
 
   players_iterate(pplayer) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9037) memory leak in score reporting, Jason Short <=