Opened 13 years ago

Closed 13 years ago

#4642 closed patch (fixed)

invalidated iterator

Reported by: Erik Hovland <erik@…> Owned by: danielk
Priority: minor Milestone: 0.21
Component: mythtv Version: head
Severity: low Keywords:
Cc: Ticket locked: no


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)

invalidated-iterator (1.2 KB) - added by Erik Hovland <erik@…> 13 years ago.
changes do loop for for loop and attempts to keep iterator valid

Download all attachments as: .zip

Change History (3)

Changed 13 years ago by Erik Hovland <erik@…>

Attachment: invalidated-iterator added

changes do loop for for loop and attempts to keep iterator valid

comment:1 Changed 13 years ago by danielk

Owner: changed from Isaac Richards to danielk
Status: newassigned

comment:2 Changed 13 years ago by danielk

Resolution: fixed
Status: assignedclosed

(In [16000]) Fixes #4642. Make sure iterator is still valid after an item has been deleted from list in FireWireDevice::RemoveListener?().

Note: See TracTickets for help on using tickets.