Skip to content

Commit

Permalink
[Orchagent]: Fixbug segmentfault at routeorch (#1025)
Browse files Browse the repository at this point in the history
The log statement will cause segmentfault if `observerEntry->second.routeTable` is empty.

Signed-off-by: Ze Gan <ganze718@gmail.com>
  • Loading branch information
Pterosaur authored and yxieca committed Aug 16, 2019
1 parent 950e9db commit 384c21e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,13 @@ void RouteOrch::attach(Observer *observer, const IpAddress& dstAddr)

observerEntry->second.observers.push_back(observer);

SWSS_LOG_NOTICE("Attached next hop observer of route %s for destination IP %s",
observerEntry->second.routeTable.rbegin()->first.to_string().c_str(),
dstAddr.to_string().c_str());

// Trigger next hop change for the first time the observer is attached
auto route = observerEntry->second.routeTable.rbegin();
if (route != observerEntry->second.routeTable.rend())
{
SWSS_LOG_NOTICE("Attached next hop observer of route %s for destination IP %s",
observerEntry->second.routeTable.rbegin()->first.to_string().c_str(),
dstAddr.to_string().c_str());
NextHopUpdate update = { dstAddr, route->first, route->second };
observer->update(SUBJECT_TYPE_NEXTHOP_CHANGE, static_cast<void *>(&update));
}
Expand Down

0 comments on commit 384c21e

Please sign in to comment.