Skip to content

Undefined behavior in destructors #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pmarcelll opened this issue Jan 15, 2014 · 3 comments
Closed

Undefined behavior in destructors #126

pmarcelll opened this issue Jan 15, 2014 · 3 comments
Assignees
Milestone

Comments

@pmarcelll
Copy link

I recently started to use Arch Linux after an old Ubuntu system and wanted to use the always up-to-date packages. I installed the cppcheck utility and tested it on the hawaii-shell codebase. I've found a similar bug in three destructors:
src/server/shell.cpp:192
src/server/effects/inoutsurfaceeffect.cpp:73
src/server/effects/minimizeeffect.cpp:97

After calling erase(), the iterator becomes invalid, so ++i is undefinde behavior.
The solution is decribed here: http://stackoverflow.com/questions/4260891/can-i-remove-elements-from-stdlist-when-im-iterating-on-it.

@pmarcelll
Copy link
Author

There are also a couple of warnings, for example:
src/server/workspace.cpp:115 two returns in a function
members are not initialized in constructor
missing copy constructor (class contains a pointer to allocated memory)
...

@ghost ghost assigned plfiorini Jan 15, 2014
plfiorini added a commit that referenced this issue Jan 21, 2014
plfiorini added a commit that referenced this issue Jan 21, 2014
@pmarcelll
Copy link
Author

I forgot to close it, but it's okay now.

@plfiorini plfiorini modified the milestones: Version 0.3.0, Version 0.2.1 Feb 23, 2014
@pmarcelll
Copy link
Author

I ran cppcheck again on the dev branch, cdb8751 added back the redundant return (55362ce).

@pmarcelll pmarcelll reopened this Apr 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants