Skip to content

Commit 16aac31

Browse files
committed
eigrp: bugfix: flushMsgRequests(): Dangling pointer usage in second for-loop.
1 parent 385f11b commit 16aac31

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

src/inet/routing/eigrp/pdms/EigrpIpv4Pdm.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,18 +1354,23 @@ void EigrpIpv4Pdm::flushMsgRequests()
13541354
// Check if interface exists
13551355
if (eigrpIft->findInterfaceById(item->getDestInterface()) != nullptr) {
13561356
send(item, RTP_OUTGW);
1357+
item = nullptr;
13571358
}
13581359
}
13591360
}
13601361

13611362
// Send or delete other messages
13621363
for (auto& item : reqQueue) {
1363-
// Check if interface exists
1364-
if (eigrpIft->findInterfaceById(item->getDestInterface()) == nullptr) {
1365-
delete item; // Discard request
1366-
}
1367-
else if (item->getOpcode() != EIGRP_QUERY_MSG) {
1368-
send(item, RTP_OUTGW);
1364+
if (item != nullptr) {
1365+
// Check if interface exists
1366+
if (eigrpIft->findInterfaceById(item->getDestInterface()) == nullptr) {
1367+
delete item; // Discard request
1368+
item = nullptr;
1369+
}
1370+
else if (item->getOpcode() != EIGRP_QUERY_MSG) {
1371+
send(item, RTP_OUTGW);
1372+
item = nullptr;
1373+
}
13691374
}
13701375
}
13711376

src/inet/routing/eigrp/pdms/EigrpIpv6Pdm.cc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,23 +1346,26 @@ void EigrpIpv6Pdm::flushMsgRequests()
13461346
for (auto& item : reqQueue) {
13471347
if (item->getOpcode() == EIGRP_QUERY_MSG) {
13481348
// Check if interface exists
1349-
if (eigrpIft->findInterfaceById(item->getDestInterface()) == nullptr)
1350-
continue;
1351-
else
1349+
if (eigrpIft->findInterfaceById(item->getDestInterface()) != nullptr) {
13521350
send(item, RTP_OUTGW);
1351+
item = nullptr;
1352+
}
13531353
}
13541354
}
13551355

13561356
// Send other messages
13571357
for (auto& item : reqQueue) {
1358-
// Check if interface exists
1359-
if (eigrpIft->findInterfaceById(item->getDestInterface()) == nullptr) {
1360-
delete item; // Discard request
1361-
continue;
1358+
if (item != nullptr) {
1359+
// Check if interface exists
1360+
if (eigrpIft->findInterfaceById(item->getDestInterface()) == nullptr) {
1361+
delete item; // Discard request
1362+
item = nullptr;
1363+
}
1364+
else if (item->getOpcode() != EIGRP_QUERY_MSG) {
1365+
send(item, RTP_OUTGW);
1366+
item = nullptr;
1367+
}
13621368
}
1363-
1364-
if (item->getOpcode() != EIGRP_QUERY_MSG)
1365-
send(item, RTP_OUTGW);
13661369
}
13671370

13681371
reqQueue.clear();

0 commit comments

Comments
 (0)