Opened 16 years ago
Closed 16 years ago
#4642 closed patch (fixed)
invalidated iterator
Reported by: | Owned by: | danielk | |
---|---|---|---|
Priority: | minor | Milestone: | 0.21 |
Component: | mythtv | Version: | head |
Severity: | low | Keywords: | |
Cc: | Ticket locked: | no |
Description
In firewiredevice.cpp at about line 49, the member function FirewireDevice::RemoveListener? enters into a do loop where it attempts to remove all listeners with a given name from the list of listeners for the object. If a listener is found it is removed using the list member function erase. At that point the iterator assocaited to the listener has been invalidated by the erase call. But at the end of the do loop the iterator is tested. Invalidated iterator testing is undefined. And while this likely works for most instances of gcc it is possible for stl implementors to delete the iterator. Which means the testing could cause a segfault.
The attached patch attempts to address this problem by changing the do loop to a for loop (only to use the more common idiom for stl lists) and then attempting to do the right thing with the iterator so it is not invalidated before testing.
Attachments (1)
Change History (3)
Changed 16 years ago by
Attachment: | invalidated-iterator added |
---|
comment:1 Changed 16 years ago by
Owner: | changed from Isaac Richards to danielk |
---|---|
Status: | new → assigned |
comment:2 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [16000]) Fixes #4642. Make sure iterator is still valid after an item has been deleted from list in FireWireDevice::RemoveListener?().
changes do loop for for loop and attempts to keep iterator valid