pybox2d / pybox2d

2D Game Physics for Python
Other
481 stars 93 forks source link

Fix #119, DestroyBody may trigger EndContact. #124

Closed xzfn closed 3 years ago

xzfn commented 3 years ago

DestroyBody may trigger EndContact. Py_XDECREF may cause userData to be released before DestroyBody.

Here we put the Py_XDECREF after DestroyBody. So in EndContact callback the userData should be valid.

It's still not 100% safe. Bad thing will happen if user code try to change userData in EndContact callback called from DestroyBody. It should be safer than before though.

coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 0.0% when pulling 9172d95becefb40ba835639bb85b3707e7e94532 on xzfn:fix_119 into f8617198555d2e1539b0be82f0ee6e7db4d26085 on pybox2d:master.