mem: Avoid using invalid iterator in cache lock list traversal

Fix up issue highlighted by Valgrind and the clang Address Sanitizer.
This commit is contained in:
Andreas Hansson 2016-02-15 03:40:04 -05:00
parent b181cea364
commit 407233f5d8

View file

@ -347,15 +347,16 @@ class CacheBlk
bool success = false;
auto l = lockList.begin();
while (l != lockList.end() && !success) {
while (!success && l != lockList.end()) {
if (l->matches(pkt->req)) {
// it's a store conditional, and as far as the
// memory system can tell, the requesting
// context's lock is still valid.
success = true;
lockList.erase(l);
} else {
++l;
}
++l;
}
req->setExtraData(success ? 1 : 0);