This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfa] add_symbol_file_command, avoid memory leak.
On Sun, 27 Feb 2011 22:57:09 +0100, Michael Snyder wrote:
> @@ -2169,15 +2169,15 @@ add_symbol_file_command (char *args, int
> size_t num_sect_opts = 0;
> struct cleanup *my_cleanups = make_cleanup (null_cleanup, NULL);
>
> - num_sect_opts = 16;
> - sect_opts = (struct sect_opt *) xmalloc (num_sect_opts
> - * sizeof (struct sect_opt));
> -
> dont_repeat ();
>
> if (args == NULL)
> error (_("add-symbol-file takes a file name and an address"));
>
> + num_sect_opts = 16;
> + sect_opts = (struct sect_opt *) xmalloc (num_sect_opts
> + * sizeof (struct sect_opt));
> +
> argv = gdb_buildargv (args);
> make_cleanup_freeargv (argv);
>
> How about this?
Yes, the fix is OK now. There could be also added some
make_cleanup (xfree, sect_opts);
as discussed before; but it may be a different patch.
Thanks,
Jan