This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR58803 - Prevent a double-free with proc-pointer components


On Mon, Oct 21, 2013 at 07:15:07PM +0200, Tobias Burnus wrote:
> -      c->tb = tb;
> +      if (num == 1)
> +	c->tb = tb;
> +      else
> +	{
> +	  c->tb = XCNEW (gfc_typebound_proc);
> +	  c->tb->where = gfc_current_locus;
> +	  *c->tb = *tb;

I haven't convinced myself yet, but is this leaking memory?

Lines 5006-7 are

  tb = XCNEW (gfc_typebound_proc);
  tb->where = gfc_current_locus;

In the num = 1 case, c->tb = tb and I presume during teardown
c->tb is freed and by extension tb.  But, in the else case,
are you copying the contents from *tb into *c->tb and the tb
is never freed?

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]