[Scummvm-tracker] [ScummVM :: Bugs] #11494: BASE: Possible use of invalid iterators

ScummVM :: Bugs trac at scummvm.org
Mon Aug 31 18:08:20 UTC 2020


#11494: BASE: Possible use of invalid iterators
----------------------+------------------------------------------
  Reporter:  Tkachov  |      Owner:  criezy
      Type:  defect   |     Status:  closed
  Priority:  high     |  Component:  --Unset--
Resolution:  fixed    |   Keywords:  iterators, invalidate, erase
      Game:           |
----------------------+------------------------------------------
Changes (by criezy):

 * owner:  (none) => criezy
 * status:  new => closed
 * resolution:   => fixed

Comment:

 Thank you for the reports.
 The good news is that they are all false positive.

 ----

 '''DefaultTimerManager''': This is a false positive as _callbacks is a
 `Common::HashMap` and calling `HashMap::erase(iterator)` does not
 invalidate iterators. Even iterators on the erased node remain partially
 valid. They can no longer be dereferenced, but can still be used for the
 iteration. Also `erase()` does not actually return anything.

 ----

 '''Ultima8''': This is also a false positive. This time the code is using
 a `Std::list` that derives from `Common::List`. `Common::List` is
 implemented as a linked list, and erase only invalidates iterators
 pointing to the erased item.

 ----

 '''Cruise''' and '''Tony''': Again false positives. They are using a
 `Common::List<Common::Rect>` (so again only iterators to the erased items
 are invalidated).

 ----

 '''ZVision''': `_subsList` is a `SubtitleMap` which is a typedef tp a
 `Common::HashMap`. So the code is actually correct (`HashMap::erase()`
 does not return an iterator, and we can continue iterating using the
 current one).

 ----

 '''Gob''': `_opcodesGob` is a `Common::HashMap`. So `erase()` does not
 return anything and does not invalidate iterators.
-- 
Ticket URL: <https://bugs.scummvm.org/ticket/11494#comment:3>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM


More information about the Scummvm-tracker mailing list