[bgpd] Potential bug#287 fix, peer_delete should NULL out freed buffers

2006-07-27 Paul Jakma <paul.jakma@sun.com>

	* bgpd.c: (peer_delete) Ensure freed buffers can not be
	  accidently reused. A potential fix for bug #287.
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index a8a6c35..90d0e0e 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-27 Paul Jakma <paul.jakma@sun.com>
+
+	* bgpd.c: (peer_delete) Ensure freed buffers can not be
+	  accidently reused. A potential fix for bug #287.
+
 2006-07-02 Paul Jakma <paul.jakma@sun.com>
 
 	* bgp_fsm.c: (bgp_{stop,start}) Move clear/free of certain
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index b574a9a..8ed598d 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1205,18 +1205,19 @@
   /* Buffers.  */
   if (peer->ibuf)
     stream_free (peer->ibuf);
-  
   if (peer->obuf)
     stream_fifo_free (peer->obuf);
-
   if (peer->work)
     stream_free (peer->work);
-  
+  peer->obuf = NULL;
+  peer->work = peer->ibuf = NULL;
+
   /* Local and remote addresses. */
   if (peer->su_local)
     sockunion_free (peer->su_local);
   if (peer->su_remote)
     sockunion_free (peer->su_remote);
+  peer->su_local = peer->su_remote = NULL;
   
   bgp_sync_delete (peer);