DestroyBody EXC_BAD_ACCESS b2JointEdge* je = b->m_jointList

Hi,

I'm trying to destroy bodies, but keep getting
Program received signal: “EXC_BAD_ACCESS”.
And the code jumps to b2World.cpp void - b2World::DestroyBody(b2Body* b) with a red arrow at:
b2JointEdge* je = b->m_jointList;

The only thing I have done with this sprite/body before destroying it is create it/display it and then in the ccTouchesBegan:
Code:
for (b2Fixture* f = mySpritesBody->GetFixtureList(); f; f = f->GetNext()) {
            if (f->TestPoint(touchCoords)) {
               [self mySpriteTouched];
            }
         }


[self mySpriteTouched]; is a method where the sprite/body is destroyed:

Code:
[gameLayer removeChild:mySprite cleanup:YES];
_world->DestroyBody(mySpritesBody);


So I create the sprite and its body and then if it gets touched (attempt to) destroy it.
I know my sprite/body creation is working because I have another sprite and body which I create that gets destroyed if the user touches a certain other sprite on the screen. This works fine and the sprite and body both disappear. So the only difference as far as I can see is the bit in the touchesBegan.

Any ideas what's wrong?
Thanks for any help...
Update:

I guess the problem might be to do with destroying a body and so also its fixtures and the for loop still trying to run through fixtures that are no longer there. If so, how can I stop the for loop running if the body gets destroyed? I have the loop as I have more than 1 fixture per body.
Ok seems I've worked it out:
Code:
         bool touched = false;
         
         for (b2Fixture* f = mySpritesBody->GetFixtureList(); f; f = f->GetNext()) {
            if (f->TestPoint(touchCoords)) {
               [self mySpriteTouched];
               touched = true;
            }
            if (touched == true) {
               break;
            }
         }


Don't know if its the best way to do it, but it seems to work.

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