On Tue, May 06, 2014 at 03:32:06PM +0200, Jérémie Courrèges-Anglas wrote:
> Denis Fondras <[email protected]> writes:
> 
> >> By the OS, which cleans up after the process exits.  If it wasn't that
> >> way, we'd all have a much shorter uptime...
> >> 
> >
> > Thank you Jérémie :)
> > I had not considered it as I can see
> >
> > ...
> > free(ibuf_rde);
> > ...
> > free(ibuf_main);
> > ...
> >
> > at the end of session_main() in session.c.
> 
> Maybe you should consider this as "best effort".  It's a good thing to
> clean up at the end of a function in an executable, even in error cases
> where the end result is exit(1) / err() / fatal(), because code gets
> copied and used in different contexts (where cleaning up could be
> necessary).

Bad advice, you should not cleanup before err() or fatal() ever.
It could very well be that you hit a bug that trashed your heap and
calling free() will not solve anything. Doing cleanup before exit is only
used to check for memleaks with simple tools.
 
> But from discussions on tech@ a few months ago, you'll see that there is
> no real interest in amending those non-problems if no true audit is
> done to track down all occurrences in a particular piece of software.
> 
> That said, thid diff works fine on a simple test setup.
> 
> Index: session.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
> retrieving revision 1.334
> diff -u -p -p -u -r1.334 session.c
> --- session.c 22 Jan 2014 04:08:08 -0000      1.334
> +++ session.c 6 May 2014 13:21:26 -0000
> @@ -599,6 +599,7 @@ session_main(int pipe_m2s[2], int pipe_s
>               free(la);
>       }
>       free(conf->listen_addrs);
> +     free(conf);
>       free(peer_l);
>       free(mrt_l);
>       free(pfd);
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE
> 

-- 
:wq Claudio

Reply via email to