wgois / OIS

Official OIS repository. Object oriented Input System

Home Page:https://wgois.github.io/OIS/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OISInputManager.cpp:255: bad erase ?

dcb314 opened this issue · comments

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

Source code is

            mFactoryObjects.erase(i++);

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 ;-)

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.