Memory leak in BgpTable::CreateAsPath4Byte()

Bug #1801569 reported by Ananth Suryanarayana
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Juniper Openstack
Status tracked in Trunk
Trunk
Fix Committed
High
Ananth Suryanarayana

Bug Description

diff --git a/src/bgp/bgp_table.cc b/src/bgp/bgp_table.cc
index 302ceda..d776e74 100644
--- a/src/bgp/bgp_table.cc
+++ b/src/bgp/bgp_table.cc
@@ -433,7 +433,7 @@ void BgpTable::CreateAsPath2Byte(BgpAttr *attr, as_t local_as) const {

 // Create aspath_4byte by merging as_path and as4_path
 void BgpTable::CreateAsPath4Byte(BgpAttr *attr, as_t local_as) const {
- AsPath4ByteSpec *aspath_4byte = new AsPath4ByteSpec;
+ boost::scoped_ptr<AsPath4ByteSpec> aspath_4byte(new AsPath4ByteSpec);
     if (attr->as_path()) {
         const AsPathSpec &as_path = attr->as_path()->path();
         if (attr->as4_path()) {
@@ -468,9 +468,9 @@ void BgpTable::CreateAsPath4Byte(BgpAttr *attr, as_t local_as) const {
             }
         }
     }
- AsPath4ByteSpec *as_path_ptr = aspath_4byte->Add(local_as);
- attr->set_aspath_4byte(as_path_ptr);
- delete as_path_ptr;
+ boost::scoped_ptr<AsPath4ByteSpec> as_path_spec(
+ aspath_4byte->Add(local_as));
+ attr->set_aspath_4byte(as_path_spec.get());
 }

 bool BgpTable::IsAsPathLoop(const RibOut *ribout, const BgpAttr *attr) const {

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : [Review update] master

Review in progress for https://review.opencontrail.org/47458
Submitter: Ananth Suryanarayana (<email address hidden>)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : A change has been merged

Reviewed: https://review.opencontrail.org/47458
Committed: http://github.com/Juniper/contrail-controller/commit/144202befea2703b500ed52e8303bdff26f45703
Submitter: Zuul v3 CI (<email address hidden>)
Branch: master

commit 144202befea2703b500ed52e8303bdff26f45703
Author: Ananth Suryanarayana <email address hidden>
Date: Sat Nov 3 23:30:08 2018 -0700

Fix memory leak in BgpTable::CreateAsPath4Byte

Use boost::scoped_ptr to free allocated memory automatically.

Change-Id: If14fb98851d115304b75b6c337529a533d5a7e96
Closes-Bug: 1801569

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.