Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9612) memory leak in compressed packets
Home

[Freeciv-Dev] (PR#9612) memory leak in compressed packets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9612) memory leak in compressed packets
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Aug 2004 10:12:00 -0700
Reply-to: rt@xxxxxxxxxxx

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

==7211== 62836 bytes in 79 blocks are definitely lost in loss record 15 
of 16
==7211==    at 0x1B904EDD: malloc (vg_replace_malloc.c:131)
==7211==    by 0x804B23E: fc_real_malloc (mem.c:79)
==7211==    by 0x80D899D: send_packet_data (packets.c:164)
==7211==    by 0x80DAFF1: send_packet_processing_finished_100 
(packets_gen.c:834)
==7211==    by 0x80DB1CD: send_packet_processing_finished 
(packets_gen.c:889)
==7211==    by 0x80B0A9F: finish_processing_request (sernet.c:901)
==7211==    by 0x80B00D7: sniff_packets (sernet.c:622)
==7211==    by 0x805142B: srv_loop (srv_main.c:1640)
==7211==    by 0x805112C: srv_main (srv_main.c:1531)
==7211==    by 0x804A5DE: main (civserver.c:161)

I believe the attached patch fixes this.  No new valgrind errors show up 
  under this.

jason

Index: common/packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.268
diff -u -r1.268 packets.c
--- common/packets.c    29 Jul 2004 00:09:27 -0000      1.268
+++ common/packets.c    5 Aug 2004 17:11:09 -0000
@@ -161,7 +161,7 @@
       if (pc->compression.frozen_level == 0) {
        long int compressed_size = 12 + pc->compression.queue_size * 1.001;
        int error;
-       void *compressed = fc_malloc(compressed_size);
+       char compressed[compressed_size];
 
        error =
            compress2(compressed, &compressed_size,

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9612) memory leak in compressed packets, Jason Short <=