Author Topic: bug in configmanager.cpp and patch file  (Read 5556 times)

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
bug in configmanager.cpp and patch file
« on: December 02, 2015, 12:22:01 pm »
hi everybody,

found a bug in configmanager.cpp which can lead to undefined behaviour. probably harmless...

but patch attached.

function used map.erase(iterator) and then tries to increment that iterator in the next loop and use it again. this is undefined according to both wx documentation and stl documentation.

replaced call to map.erase(iter) inside the loop with call to clear map.clear() after the loop

regards
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: bug in configmanager.cpp and patch file
« Reply #1 on: December 02, 2015, 01:09:48 pm »
patch has an error

attached the correct one
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: bug in configmanager.cpp and patch file
« Reply #2 on: December 03, 2015, 05:06:27 am »
This will probably cause a crash someday. Will apply it next week, when I get access to my computer back.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: bug in configmanager.cpp and patch file
« Reply #3 on: December 05, 2015, 04:16:55 pm »
The patch is in trunk now, thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.