std::string constructor corrupts pointer

Posted by computergeek6 on Stack Overflow See other posts from Stack Overflow or by computergeek6
Published on 2010-03-14T21:48:57Z Indexed on 2010/03/14 21:55 UTC
Read the original article Hit count: 221

Filed under:
|
|
|

I have an Entity class, which contains 3 pointers: m_rigidBody, m_entity, and m_parent. Somewhere in Entity::setModel(std::string model), it's crashing. Apparently, this is caused by bad data in m_entity. The weird thing is that I nulled it in the constructor and haven't touched it since then. I debugged it and put a watchpoint on it, and it comes up that the m_entity member is being changed in the constructor for std::string that's being called while converting a const char* into an std::string for the setModel call. I'm running on a Mac, if that helps (I think I remember some problem with std::string on the Mac). Any ideas about what's going on?

© Stack Overflow or respective owner

Related posts about c++

Related posts about string