mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-14 22:00:05 +00:00
fix memory leak reported in Issue #1800
avoid access to array elements outside of range
This commit is contained in:
parent
f0c8bbf1a1
commit
a696bd6a46
@ -5022,8 +5022,10 @@ bool PhysicsServerCommandProcessor::processSyncUserDataCommand(const struct Shar
|
|||||||
|
|
||||||
b3AlignedObjectArray<int> userDataHandles;
|
b3AlignedObjectArray<int> userDataHandles;
|
||||||
m_data->m_userDataHandles.getUsedHandles(userDataHandles);
|
m_data->m_userDataHandles.getUsedHandles(userDataHandles);
|
||||||
memcpy(bufferServerToClient, &userDataHandles[0], sizeof(int) * userDataHandles.size());
|
if (userDataHandles.size())
|
||||||
|
{
|
||||||
|
memcpy(bufferServerToClient, &userDataHandles[0], sizeof(int) * userDataHandles.size());
|
||||||
|
}
|
||||||
serverStatusOut.m_syncUserDataArgs.m_numUserDataIdentifiers = userDataHandles.size();
|
serverStatusOut.m_syncUserDataArgs.m_numUserDataIdentifiers = userDataHandles.size();
|
||||||
serverStatusOut.m_type = CMD_SYNC_USER_DATA_COMPLETED;
|
serverStatusOut.m_type = CMD_SYNC_USER_DATA_COMPLETED;
|
||||||
return hasStatus;
|
return hasStatus;
|
||||||
|
@ -181,11 +181,12 @@ struct btCompoundCompoundLeafCallback : btDbvt::ICollide
|
|||||||
|
|
||||||
|
|
||||||
btSimplePair* pair = m_childCollisionAlgorithmCache->findPair(childIndex0,childIndex1);
|
btSimplePair* pair = m_childCollisionAlgorithmCache->findPair(childIndex0,childIndex1);
|
||||||
|
bool removePair = false;
|
||||||
btCollisionAlgorithm* colAlgo = 0;
|
btCollisionAlgorithm* colAlgo = 0;
|
||||||
if (m_resultOut->m_closestPointDistanceThreshold > 0)
|
if (m_resultOut->m_closestPointDistanceThreshold > 0)
|
||||||
{
|
{
|
||||||
colAlgo = m_dispatcher->findAlgorithm(&compoundWrap0, &compoundWrap1, 0, BT_CLOSEST_POINT_ALGORITHMS);
|
colAlgo = m_dispatcher->findAlgorithm(&compoundWrap0, &compoundWrap1, 0, BT_CLOSEST_POINT_ALGORITHMS);
|
||||||
|
removePair = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -223,7 +224,11 @@ struct btCompoundCompoundLeafCallback : btDbvt::ICollide
|
|||||||
m_resultOut->setBody0Wrap(tmpWrap0);
|
m_resultOut->setBody0Wrap(tmpWrap0);
|
||||||
m_resultOut->setBody1Wrap(tmpWrap1);
|
m_resultOut->setBody1Wrap(tmpWrap1);
|
||||||
|
|
||||||
|
if (removePair)
|
||||||
|
{
|
||||||
|
colAlgo->~btCollisionAlgorithm();
|
||||||
|
m_dispatcher->freeCollisionAlgorithm(colAlgo);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user