Commit 73372e3a authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

[master] Corrected valgrind error reported in D2UpdateMgr unit test.

D2UpdateMgr::checkFinishedTransaction was issuing an invalid read
when attempting to prefix increment an iterator used in an std::map erase
call.  This was flagged by valgrind and also core dumped under FreeBSD10.
parent 34081cbf
...@@ -74,21 +74,24 @@ D2UpdateMgr::checkFinishedTransactions() { ...@@ -74,21 +74,24 @@ D2UpdateMgr::checkFinishedTransactions() {
// for finished transactions. // for finished transactions.
// At the moment all we do is remove them from the list. This is likely // At the moment all we do is remove them from the list. This is likely
// to expand as DHCP_DDNS matures. // to expand as DHCP_DDNS matures.
// NOTE: One must use postfix increments of the iterator on the calls
// to erase. This replaces the old iterator which becomes invalid by the
// erase with a the next valid iterator. Prefix incrementing will not
// work.
TransactionList::iterator it = transaction_list_.begin(); TransactionList::iterator it = transaction_list_.begin();
while (it != transaction_list_.end()) { while (it != transaction_list_.end()) {
NameChangeTransactionPtr trans = (*it).second; NameChangeTransactionPtr trans = (*it).second;
switch (trans->getNcrStatus()) { switch (trans->getNcrStatus()) {
case dhcp_ddns::ST_COMPLETED: case dhcp_ddns::ST_COMPLETED:
transaction_list_.erase(it); transaction_list_.erase(it++);
break; break;
case dhcp_ddns::ST_FAILED: case dhcp_ddns::ST_FAILED:
transaction_list_.erase(it); transaction_list_.erase(it++);
break; break;
default: default:
break; break;
} }
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment