Re: Fix for PR 10736

Pedro Alves
2010-03-30T10:44:35Z

On Tuesday 30 March 2010 01:01:47, Sergio Durigan Junior wrote:
> Hello guys,
>
> The following patch is a fix for PR 10736.

Thanks!

> OK?

Almost. There's just a leak to fix.

> + /* Should we re-read the XML info for this target? */
> + if (my_gdb_datadir && strcmp (my_gdb_datadir, gdb_datadir) != 0)
> + {
> + /* The data-directory changed from the last time we used it.
> + It means that we have to re-read the XML info. */
> + have_initialized_sysinfo = 0;
> + xfree (my_gdb_datadir);
> + my_gdb_datadir = NULL;

The previous data dir is only released if the datadir changed.

> + if (sysinfo)
> + free_syscalls_info ((void *) sysinfo);
> + }

> +
> + /* Saving the data-directory used to read this XML info. */
> + my_gdb_datadir = xstrdup (gdb_datadir);

So here my_gdb_datadir leaks if the datadir _doesn't_ change.
I think you just need to move the xfree and my_data_dir=NULL
statements outside the `if', before the early return.
Anyway, okay with this leak fixed.

--
Pedro Alves