Daniel Jacobowitz (drow@false.org): > On Wed, Jan 21, 2009 at 11:53:48AM +0100, Jerome Guitton wrote: > > + if (!initialized) > > + { > > + struct stat homebuf, cwdbuf, s; > > + char *homedir, *relocated_sysgdbinit; > > + > > + if (stat (SYSTEM_GDBINIT, &s) == 0) > > + sysgdbinit = SYSTEM_GDBINIT; > > What, if anything, does SYSTEM_GDBINIT get defined to when GDB is > configured with no special options? It gets defined to "". It is probably clearer to make a special case; I'll do that. > > + if (homedir) > > + { > > + homeinit = xstrprintf ("%s/%s", homedir, gdbinit); > > + if (stat (homeinit, &homebuf) != 0) > > + homeinit = NULL; > > + > > + stat (homeinit, &homebuf); > > + } > > You've got a bunch of memory leaks in this function; this is one of > them. homeinit is not freed if it does not exist. True. Even worse, this second call to stat is bogus. Sorry about that. The patch in attachment should fix this and a couple of memory leaks. Could you check that it is OK this time? Thanks, Jerome 2009-01-26 Daniel Jacobowitz Jerome Guitton * configure, config.in: Regenerated. * configure.ac: Add --with-system-gdbinit. * main.c (get_init_files): New. (captured_main): Use get_init_files. Load system gdbinit before $HOME/.gdbinit. (print_gdb_help): Print location of init files.