Author: mir3x
Date: Thu Feb  2 20:50:46 2017
New Revision: 34938

URL: http://svn.gna.org/viewcvs/freeciv?rev=34938&view=rev
Log:
Fixed memory leaks when rereading tileset.

See patch #8102


Modified:
    branches/S3_0/client/tilespec.c

Modified: branches/S3_0/client/tilespec.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/tilespec.c?rev=34938&r1=34937&r2=34938&view=diff
==============================================================================
--- branches/S3_0/client/tilespec.c     (original)
+++ branches/S3_0/client/tilespec.c     Thu Feb  2 20:50:46 2017
@@ -1274,7 +1274,6 @@
   enum client_states state = client_state();
   const char *name = new_tileset_name ? new_tileset_name : tileset->name;
   char tileset_name[strlen(name) + 1], old_name[strlen(tileset->name) + 1];
-  int i;
 
   /* Make local copies since these values may be freed down below */
   sz_strlcpy(tileset_name, name);
@@ -1292,11 +1291,7 @@
    *
    * We free all old data in preparation for re-reading it.
    */
-  tileset_free_tiles(tileset);
-  tileset_free_toplevel(tileset);
-  for (i = 0; i < ARRAY_SIZE(tileset->sprites.player); i++) {
-    tileset_player_free(tileset, i);
-  }
+  tileset_free(tileset);
 
   /* Step 2:  Read.
    *
@@ -2513,6 +2508,7 @@
         get_sprite_dimensions(s, &w, &h);
         ss->sprite = crop_sprite(s, 0, 0, w,
                                  h, NULL, -1, -1, t->scale);
+        free_sprite(s);
       } else {
         ss->sprite = load_gfx_file(ss->file);
       }


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to