JoaoMGomes / libjingle

Automatically exported from code.google.com/p/libjingle
0 stars 0 forks source link

[Coverity] Using invalid iterator #261

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is a coverity generated bug:

In cricket::​SessionDescription::​RemoveGroupByName(std::basic_string<char, 
std::​char_traits<char>, std::​allocator<char>> const&):
An invalid or past-the-end iterator is being used (CWE-119)

CID 102598: Using invalid iterator (INVALIDATE_ITERATOR)
Using invalid iterator "iter".
At conditional (1): "iter != this->groups_.end()" taking the true branch.
At conditional (2): "iter->semantics() == name" taking the true branch.
"erase" invalidates iterator "iter".

void SessionDescription::RemoveGroupByName(const std::string& name) {
113  for (ContentGroups::iterator iter = groups_.begin();
114       iter != groups_.end(); ++iter) {
115    if (iter->semantics() == name) {
116      groups_.erase(iter);
117    }
118  }
119}

Attached is a patch that fixes it.

Original issue reported on code.google.com by binji@chromium.org on 20 Dec 2011 at 11:25

Attachments:

GoogleCodeExporter commented 9 years ago
Mallinath, can you land this patch?

Original comment by juberti@google.com on 21 Dec 2011 at 11:04

GoogleCodeExporter commented 9 years ago
Mallinath, did this get fixed?

Original comment by juberti@google.com on 24 Apr 2012 at 3:33

GoogleCodeExporter commented 9 years ago
This shouldn't be a problem any more with recent changes we have made to 
sessiondescription.cc

Original comment by mallinath@google.com on 26 Apr 2012 at 1:02