access violation while getting body

Hi,

Why does the following give me an access violation in memory?

int count = m_world->Query(aabb, shapes, k_maxCount);
b2Body* aBody = shapes[0]->GetBody();
Object* aObject = (Object*)aBody->m_userData;

If it is wrong....then what is the correct way of accessing the body?
First you should check i 'count' returned by Query is non zero. Otherwise pointer read from uninitialized shapes table may be invalid.
Then, check if body pointer (aBody) is not null before accessing it. This could help you pin the error.
gee thanks... 😆

Original thread: https://box2d.org/forum/viewtopic.php?t=331