Skip to content

Commit b611808

Browse files
Pterosaurlguohan
authored andcommitted
[Orchagent]: Fixbug segmentfault at routeorch (#1025)
The log statement will cause segmentfault if `observerEntry->second.routeTable` is empty. Signed-off-by: Ze Gan <[email protected]>
1 parent 252e12c commit b611808

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

orchagent/routeorch.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,14 @@ void RouteOrch::attach(Observer *observer, const IpAddress& dstAddr)
156156

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

159-
SWSS_LOG_NOTICE("Attached next hop observer of route %s for destination IP %s",
160-
observerEntry->second.routeTable.rbegin()->first.to_string().c_str(),
161-
dstAddr.to_string().c_str());
162-
163159
// Trigger next hop change for the first time the observer is attached
164160
// Note that rbegin() is pointing to the entry with longest prefix match
165161
auto route = observerEntry->second.routeTable.rbegin();
166162
if (route != observerEntry->second.routeTable.rend())
167163
{
164+
SWSS_LOG_NOTICE("Attached next hop observer of route %s for destination IP %s",
165+
observerEntry->second.routeTable.rbegin()->first.to_string().c_str(),
166+
dstAddr.to_string().c_str());
168167
NextHopUpdate update = { dstAddr, route->first, route->second };
169168
observer->update(SUBJECT_TYPE_NEXTHOP_CHANGE, static_cast<void *>(&update));
170169
}

0 commit comments

Comments
 (0)