------- Comment #4 from kargl at gcc dot gnu dot org  2009-05-26 15:11 -------
(In reply to comment #3)
> > > The following patch to gfc_match_nullify fixes it; however, I think one 
> > > should additionally add
> > >   gfc_free_expr (new_st.expr1);
> > >   gfc_free_expr (new_st.expr2);
> > > to prevent a memory leak.
> > 
> > AFAICT, there is no leak.
> > 
> > gfc_free_statement (gfc_code *p)
> 
> Well, I only see a call to "gfc_free_statement (new_st.next)". Thus only
> "new_st->next" and not "new_st" is touched. However, we added two expressions
> to new_st, viz expr1 and expr2, which I believe need to be freed.
> 
> (Seemingly, we cannot free new_st itself, which would be simpler.)

I conflated your patch with new_st.next with your aside about the
memory leak.  Having looked at the code, I think you are correct
that in the cleanup: code path, we may need to expr1 and expr2.

valgrind doesn't run on FreeBSD.  Can you see if valgrind detects a
leak?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40246

Reply via email to