Skip to content

Commit

Permalink
Fix invalid use of vector iterator
Browse files Browse the repository at this point in the history
Once an element of a vector is erased using an iterator, that
iterator should be considered invalid and not used.  The accepted
practice is to update the iterator with the return value of the
erase method and not to increment the iterator.

CQ: SW465848
Change-Id: If6ec7887d8c2b6c6ad44a9608c474b9c118bd117
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/85220
Reviewed-by: Zachary Clark <zach@ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E Bofferding <bofferdn@us.ibm.com>
  • Loading branch information
milesg-github authored and Nicholas E Bofferding committed Oct 16, 2019
1 parent 98bf4ec commit 68ba813
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/usr/initservice/baseinitsvc/initservice.C
Expand Up @@ -1060,8 +1060,7 @@ bool InitService::unregisterShutdownEvent(msg_q_t i_msgQ)
{

for(EventRegistry_t::iterator r = iv_regMsgQ.begin();
r != iv_regMsgQ.end();
++r)
r != iv_regMsgQ.end();)
{
// erase all instances
if(r->msgQ == i_msgQ)
Expand All @@ -1072,7 +1071,11 @@ bool InitService::unregisterShutdownEvent(msg_q_t i_msgQ)
r->compID, r->msgQ, r->msgType, r->msgPriority);

result = true;
iv_regMsgQ.erase(r);
r = iv_regMsgQ.erase(r);
}
else
{
++r;
}
}
}
Expand Down

0 comments on commit 68ba813

Please sign in to comment.