Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] Re: (PR#8500) packet_single_want_hack_req isn't freed
Home

[Freeciv-Dev] Re: (PR#8500) packet_single_want_hack_req isn't freed

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#8500) packet_single_want_hack_req isn't freed
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Apr 2004 14:44:51 -0700
Reply-to: rt@xxxxxxxxxxx

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

jdorje@xxxxxxxxxxxx wrote:

> However this isn't clean because the caller gives us packet directly. 
> It should be the caller who frees it.

And a patch.

jason

Index: server/sernet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v
retrieving revision 1.116
diff -u -r1.116 sernet.c
--- server/sernet.c     17 Mar 2004 00:22:44 -0000      1.116
+++ server/sernet.c     12 Apr 2004 21:43:32 -0000
@@ -614,7 +614,10 @@
                                         pconn->server.
                                         last_request_id_seen);
                command_ok = handle_packet_input(pconn, packet, type);
-               packet = NULL;
+               if (packet) {
+                 free(packet);
+                 packet = NULL;
+               }
 
                finish_processing_request(pconn);
                connection_do_unbuffer(pconn);
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.158
diff -u -r1.158 srv_main.c
--- server/srv_main.c   10 Apr 2004 03:47:50 -0000      1.158
+++ server/srv_main.c   12 Apr 2004 21:43:32 -0000
@@ -776,7 +776,6 @@
     bool result =
        handle_login_request(pconn,
                             (struct packet_server_join_req *) packet);
-    free(packet);
     return result;
   }
 
@@ -786,20 +785,17 @@
        handle_authentication_reply(pconn,
                                    ((struct packet_authentication_reply *)
                                     packet)->password);
-    free(packet);
     return result;
   }
 
   if (type == PACKET_CONN_PONG) {
     handle_conn_pong(pconn);
-    free(packet);
     return TRUE;
   }
 
   if (!pconn->established) {
     freelog(LOG_ERROR, "Received game packet from unaccepted connection %s",
            conn_description(pconn));
-    free(packet);
     return TRUE;
   }
   
@@ -807,7 +803,6 @@
   if (type == PACKET_CHAT_MSG_REQ) {
     handle_chat_msg_req(pconn,
                        ((struct packet_chat_msg_req *) packet)->message);
-    free(packet);
     return TRUE;
   }
 
@@ -828,7 +823,6 @@
     /* don't support these yet */
     freelog(LOG_ERROR, "Received packet from non-player connection %s",
            conn_description(pconn));
-    free(packet);
     return TRUE;
   }
 
@@ -845,7 +839,6 @@
       freelog(LOG_ERROR, "got a packet of type %d "
                         "outside RUN_GAME_STATE", type);
     }
-    free(packet);
     return TRUE;
   }
 
@@ -855,7 +848,6 @@
      && !(type == PACKET_REPORT_REQ || type == PACKET_CONN_PONG)) {
     freelog(LOG_ERROR, _("Got a packet of type %d from a "
                         "dead or observer player"), type);
-    free(packet);
     return TRUE;
   }
   
@@ -871,7 +863,6 @@
     kill_dying_players();
   }
 
-  free(packet);
   pplayer->current_conn = NULL;
   return TRUE;
 }

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