mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-06-08 00:03:53 +00:00
fix some msan (memory sanitizer) issues
This commit is contained in:
@@ -75,6 +75,7 @@ bFile::bFile(const char *filename, const char headerString[7])
|
||||
fseek(fp, 0L, SEEK_SET);
|
||||
|
||||
mFileBuffer = (char *)malloc(mFileLen + 1);
|
||||
memset(mFileBuffer, 0, mFileLen+1);
|
||||
size_t bytesRead;
|
||||
bytesRead = fread(mFileBuffer, mFileLen, 1, fp);
|
||||
|
||||
|
||||
@@ -333,6 +333,7 @@ void btBulletFile::parse(int verboseMode)
|
||||
if (m_DnaCopy)
|
||||
delete m_DnaCopy;
|
||||
m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64, 16);
|
||||
memset(m_DnaCopy, 0, sBulletDNAlen64);
|
||||
memcpy(m_DnaCopy, sBulletDNAstr64, sBulletDNAlen64);
|
||||
parseInternal(verboseMode, m_DnaCopy, sBulletDNAlen64);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "b3ResourcePath.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define B3_FILEIO_MAX_FILES 1024
|
||||
|
||||
struct b3BulletDefaultFileIO : public CommonFileIOInterface
|
||||
@@ -155,6 +157,7 @@ struct b3BulletDefaultFileIO : public CommonFileIOInterface
|
||||
FILE* f = m_fileHandles[fileHandle];
|
||||
if (f)
|
||||
{
|
||||
memset(destBuffer, 0, numBytes);
|
||||
char* txt = ::fgets(destBuffer, numBytes, m_fileHandles[fileHandle]);
|
||||
for (int i=0;i<numBytes;i++)
|
||||
{
|
||||
|
||||
@@ -90,13 +90,11 @@ btManifoldResult::btManifoldResult(const btCollisionObjectWrapper* body0Wrap, co
|
||||
: m_manifoldPtr(0),
|
||||
m_body0Wrap(body0Wrap),
|
||||
m_body1Wrap(body1Wrap)
|
||||
#ifdef DEBUG_PART_INDEX
|
||||
,
|
||||
m_partId0(-1),
|
||||
m_partId1(-1),
|
||||
m_index0(-1),
|
||||
m_index1(-1)
|
||||
#endif //DEBUG_PART_INDEX
|
||||
,
|
||||
m_closestPointDistanceThreshold(0)
|
||||
{
|
||||
|
||||
@@ -72,11 +72,17 @@ public:
|
||||
btScalar distance) : m_localPointA(pointA),
|
||||
m_localPointB(pointB),
|
||||
m_normalWorldOnB(normal),
|
||||
m_positionWorldOnB(0,0,0),
|
||||
m_positionWorldOnA(0,0,0),
|
||||
m_distance1(distance),
|
||||
m_combinedFriction(btScalar(0.)),
|
||||
m_combinedRollingFriction(btScalar(0.)),
|
||||
m_combinedSpinningFriction(btScalar(0.)),
|
||||
m_combinedRestitution(btScalar(0.)),
|
||||
m_partId0(-1),
|
||||
m_partId1(-1),
|
||||
m_index0(-1),
|
||||
m_index1(-1),
|
||||
m_userPersistentData(0),
|
||||
m_contactPointFlags(0),
|
||||
m_appliedImpulse(0.f),
|
||||
@@ -88,7 +94,9 @@ public:
|
||||
m_contactCFM(0.f),
|
||||
m_contactERP(0.f),
|
||||
m_frictionCFM(0.f),
|
||||
m_lifeTime(0)
|
||||
m_lifeTime(0),
|
||||
m_lateralFrictionDir1(0,0,0),
|
||||
m_lateralFrictionDir2(0,0,0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
#include "btAlignedAllocator.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
|
||||
int gNumAlignedAllocs = 0;
|
||||
@@ -23,7 +24,9 @@ int gTotalBytesAlignedAllocs = 0; //detect memory leaks
|
||||
|
||||
static void *btAllocDefault(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
char* data = (char*) malloc(size);
|
||||
memset(data,0,size);//keep msan happy
|
||||
return data;
|
||||
}
|
||||
|
||||
static void btFreeDefault(void *ptr)
|
||||
@@ -73,6 +76,8 @@ static inline void *btAlignedAllocDefault(size_t size, int alignment)
|
||||
{
|
||||
ret = (void *)(real);
|
||||
}
|
||||
//keep msan happy
|
||||
memset((char*) ret, 0, size);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user