wgois / OIS

Official OIS repository. Object oriented Input System
https://wgois.github.io/OIS/
zlib License
256 stars 86 forks source link

OISInputManager.cpp:255: bad erase ? #21

Closed dcb314 closed 6 years ago

dcb314 commented 8 years ago

OISInputManager.cpp:255] -> [OISInputManager.cpp:250]: (warning) Missing bounds check for extra iterator increment in loop.

Source code is

            mFactoryObjects.erase(i++);
Ybalrid commented 6 years ago

You know, there are two really hard things in computer science

  1. Naming things
  2. Cache invalidation.
  3. Off-by-one errors.

I'm planning to modernize the toolchain, something like asan should help find if this is an actual error. in the mean time, I'll comb through the code to see what is going on exactly. Thanks for reporting the potential error ;-)

Ybalrid commented 6 years ago

In this particular case, what happen is that the erasing is being made on the current object pointed by "i", then nobody touches this iterator until the next times we go through the loop, and here there's a test if i != mFactoryObjects.end(). So there's no way this can cause an issue as-is.