Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13620) fix buglet in sending packet_options_settable
Home

[Freeciv-Dev] (PR#13620) fix buglet in sending packet_options_settable

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13620) fix buglet in sending packet_options_settable
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 5 Aug 2005 12:00:19 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13620 >

This patch, for 2.0, fixes a buglet in the sending of 
packet_options_settable.

The bug is that we must memset the packet to 0 on each iteration not 
just at the start, otherwise data that isn't initialized will carry over 
from the previous iteration.

There's also no reason whatsoever to make these fields static.  This 
structure is rather large (~20k).

-jason

Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.354.2.37
diff -p -u -r1.354.2.37 stdinhand.c
--- server/stdinhand.c  27 Jun 2005 14:27:13 -0000      1.354.2.37
+++ server/stdinhand.c  5 Aug 2005 18:56:26 -0000
@@ -1688,8 +1688,8 @@ void report_server_options(struct conn_l
 ******************************************************************/
 void report_settable_server_options(struct connection *dest, int which)
 {
-  static struct packet_options_settable_control control;
-  static struct packet_options_settable packet;
+  struct packet_options_settable_control control;
+  struct packet_options_settable packet;
   int i, s = 0;
 
   if (dest->access_level == ALLOW_NONE
@@ -1723,6 +1723,7 @@ void report_settable_server_options(stru
     if (!sset_is_changeable(i)) {
       continue;
     }
+    memset(&packet, 0, sizeof(packet));
 
     packet.id = s++;
     sz_strlcpy(packet.name, settings[i].name);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13620) fix buglet in sending packet_options_settable, Jason Short <=