[Freeciv-Dev] (PR#4580) server: don't leak memory during client-side got
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#4580) server: don't leak memory during client-side goto |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Wed, 16 Jul 2003 12:12:24 -0700 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
This patch frees units' client-side-goto structures at the server, to
avoid leaking memory.
Error reported by valgrind.
jason
? rc
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.262
diff -u -r1.262 unithand.c
--- server/unithand.c 2003/07/15 10:00:20 1.262
+++ server/unithand.c 2003/07/16 19:10:59
@@ -1442,6 +1442,11 @@
struct goto_route *pgr = NULL;
struct unit *punit = player_find_unit_by_id(pplayer, packet->unit_id);
+ if (punit->pgr) {
+ free(punit->pgr->pos);
+ free(punit->pgr);
+ }
+
pgr = fc_malloc(sizeof(struct goto_route));
pgr->pos = packet->pos; /* here goes the malloced packet->pos */
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.229
diff -u -r1.229 unittools.c
--- server/unittools.c 2003/07/02 19:32:47 1.229
+++ server/unittools.c 2003/07/16 19:10:59
@@ -2957,6 +2957,7 @@
index = pgr->first_index;
if (index == pgr->last_index) {
+ free(punit->pgr->pos);
free(punit->pgr);
punit->pgr = NULL;
if (punit->activity == ACTIVITY_GOTO)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#4580) server: don't leak memory during client-side goto,
Jason Short <=
|
|