Closed GoogleCodeExporter closed 9 years ago
We can make the getOverlappingPairArrayPtr() functions safe, returning a 0
pointer.
Then the called needs to check of course, but usually you will iterate over the
number of overlapping objects, so for 0 overlaps it is safe.
Original comment by erwin.coumans
on 11 Jan 2012 at 8:30
Securing the Function isn't the right way. This will be slow...
The Problem is this:
SpuGatheringCollisionDispatcher.cpp Line 209:
//send one big batch
int numTotalPairs = pairCache->getNumOverlappingPairs();
--> Error btBroadphasePair* pairPtr = pairCache->getOverlappingPairArrayPtr();
int i;
This Error is there, because getOverlappingPairArrayPtr() accesses a null
Pointer in the pairCache (numTotalPairs is 0). A simple if-Statement will
correct this here. (Don't call getOverlappingPairArrayPtr() if
getNumOverlappingPairs() is 0).
Explanation:
getOverlappingPairArrayPtr() accesses a btBroadphasePairArray which is a
btAlignedObjectArray via the statement "return &m_overlappingPairArray[0];". So
far so good. But overlappingPairArray[0] accesses the Pointer m_data[0] which
crashed because m_data is NULL if the size is 0.
Hope you correct this Error. It's really confusing for simple initialisation
tests...
Original comment by knox31...@googlemail.com
on 11 Jan 2012 at 9:52
This issue was closed by revision r2483.
Original comment by erwin.coumans
on 23 Jan 2012 at 10:04
Calls to getOverlappingPairArrayPtr likely happen very infrequent, so just a
single 0 pointer check shouldn't be slow.
Anyway, I committed the fix as you suggested. Please reply if you still hit an
error.
Original comment by erwin.coumans
on 23 Jan 2012 at 10:05
Tested and Fixed. thx
Original comment by knox31...@googlemail.com
on 25 Jan 2012 at 1:35
Original issue reported on code.google.com by
knox31...@googlemail.com
on 14 Dec 2011 at 9:37