Recommended Posts

Hey all,
I'm getting a segfault when I try to access a vector of game objects, which I've checked and looks completely correct. Segfault only happens when the vector is empty (i.e. last shot is destroyed). Here's some code that demonstrates this:

GDB tells me that there may have been a double free or corruption, if that helps.
Can anyone help me figure out what's wrong? Everything looks right AFAIK. Thanks in advance!
[Edited by - fyhuang on February 12, 2005 4:43:42 PM]

Share this post

Link to post

Share on other sites

GDB says that the code segfaults at those two places, so I guess I'll have to trust that...

The vector is not accessed in any way besides the code I just listed (and a drawing routine, but that doesn't modify it), and also at the beginning (a simple clear() ) and at the end (commenting out the one at the end didn't stop the segfault, so I'll assume that that part has no relevance).