Skip to content

Commit 139b05a

Browse files
committed
Fix invalid iterator causing undefined behaviour
1 parent 5ab89d5 commit 139b05a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/webdriver/webdriver_session.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,19 @@ void Session::UpdateViews(const std::set<ViewId>& views) {
501501
ViewsMap::iterator it;
502502
ViewId vi;
503503

504-
for (it = views_.begin(); it != views_.end(); ++it) {
504+
for (it = views_.begin(); it != views_.end();) {
505505
vi = ViewId(it->first);
506506

507507
if (vi.is_valid() && 0 == views.count(vi)) {
508+
it = views_.erase( it );
508509
// invalidate handle
509510
RemoveView(vi);
511+
break;
510512
}
513+
else
514+
{
515+
++it;
516+
}
511517
}
512518
}
513519

0 commit comments

Comments
 (0)