Author: cazfi
Date: Sat Jun 25 02:44:31 2016
New Revision: 33018

URL: http://svn.gna.org/viewcvs/freeciv?rev=33018&view=rev
Log:
Free values received from get_option_malloc() that are not needed
after parameter parsing, but were not yet freed immediately. 

See bug #24468

Modified:
    branches/S2_5/client/gui-sdl/gui_main.c
    branches/S2_5/server/civserver.c
    branches/S2_5/tools/mpcmdline.c

Modified: branches/S2_5/client/gui-sdl/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-sdl/gui_main.c?rev=33018&r1=33017&r2=33018&view=diff
==============================================================================
--- branches/S2_5/client/gui-sdl/gui_main.c     (original)
+++ branches/S2_5/client/gui-sdl/gui_main.c     Sat Jun 25 02:44:31 2016
@@ -184,14 +184,14 @@
 }
 
 /**************************************************************************
- search for command line options. right now, it's just help
- semi-useless until we have options that aren't the same across all clients.
+  Search for command line options. right now, it's just help
+  semi-useless until we have options that aren't the same across all clients.
 **************************************************************************/
 static void parse_options(int argc, char **argv)
 {
   int i = 1;
   char *option = NULL;
-    
+
   while (i < argc) {
     if (is_option("--help", argv[i])) {
       print_usage(argv[0]);
@@ -203,6 +203,7 @@
       SDL_InitSubSystem(SDL_INIT_EVENTTHREAD);
     } else if ((option = get_option_malloc("--theme", argv, &i, argc))) {
       sz_strlcpy(gui_sdl_default_theme_name, option);
+      free(option);
     } else {
       fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
       exit(EXIT_FAILURE);

Modified: branches/S2_5/server/civserver.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/civserver.c?rev=33018&r1=33017&r2=33018&view=diff
==============================================================================
--- branches/S2_5/server/civserver.c    (original)
+++ branches/S2_5/server/civserver.c    Sat Jun 25 02:44:31 2016
@@ -275,7 +275,7 @@
 #ifdef HAVE_FCDB
     } else if ((option = get_option_malloc("--Database", argv, &inx, argc))) {
       srvarg.fcdb_enabled = TRUE;
-      srvarg.fcdb_conf = option;
+      srvarg.fcdb_conf = option; /* Never freed */
     } else if (is_option("--auth", argv[inx])) {
       srvarg.auth_enabled = TRUE;
     } else if (is_option("--Guests", argv[inx])) {

Modified: branches/S2_5/tools/mpcmdline.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/tools/mpcmdline.c?rev=33018&r1=33017&r2=33018&view=diff
==============================================================================
--- branches/S2_5/tools/mpcmdline.c     (original)
+++ branches/S2_5/tools/mpcmdline.c     Sat Jun 25 02:44:31 2016
@@ -47,7 +47,7 @@
   int i = 1;
   bool ui_separator = FALSE;
   int ui_options = 0;
-  const char *option = NULL;
+  char *option = NULL;
   enum log_level loglevel = LOG_NORMAL;
 
   while (i < argc) {
@@ -107,6 +107,7 @@
         fc_fprintf(stderr, _("Try using --help.\n"));
         exit(EXIT_FAILURE);
       }
+      free(option);
     } else if (is_option("--version", argv[i])) {
       fc_fprintf(stderr, "%s \n", freeciv_name_version());
 


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

Reply via email to