Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14204) the correct color_system_free fix
Home

[Freeciv-Dev] (PR#14204) the correct color_system_free fix

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14204) the correct color_system_free fix
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 5 Oct 2005 13:17:52 -0700
Reply-to: bugs@xxxxxxxxxxx

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

The original fix in PR#14178 was wrong.  This is the correct fix.  The 
actual error wasn't that the array was freed before its members were 
freed...it was a typo that caused the player_colors entries to be freed 
twice.

-jason

Index: client/colors_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/colors_common.c,v
retrieving revision 1.12
diff -p -u -r1.12 colors_common.c
--- client/colors_common.c      4 Oct 2005 16:46:12 -0000       1.12
+++ client/colors_common.c      5 Oct 2005 20:16:00 -0000
@@ -199,12 +199,12 @@ void color_system_free(struct color_syst
       color_free(colors->player_colors[i].color);
     }
   }
+  free(colors->player_colors);
   for (i = 0; i < ARRAY_SIZE(colors->terrain_colors); i++) {
     if (colors->terrain_colors[i].color) {
-      color_free(colors->player_colors[i].color);
+      color_free(colors->terrain_colors[i].color);
     }
   }
-  free(colors->player_colors);
   while (hash_num_entries(colors->terrain_hash) > 0) {
     const char *key = hash_key_by_number(colors->terrain_hash, 0);
     const void *rgb = hash_value_by_number(colors->terrain_hash, 0);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#14204) the correct color_system_free fix, Jason Short <=