Tools/MeshExtractor: Fix uninitialized values
Fix uninitialized struct padding bytes written to output files. These bytes are actually ignored when loading these files, so the main point of this fix is to shut up the Valgrind log. Valgrind log: Syscall param write(buf) points to uninitialised byte(s) at : ??? (syscall-template.S:81) by : _IO_file_write@@GLIBC_2.2.5 (fileops.c:1270) by : new_do_write (fileops.c:546) by : _IO_do_write@@GLIBC_2.2.5 (fileops.c:519) by : _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1341) by : fwrite (iofwrite.c:43) by BuilderThread::svc() (ContinentBuilder.cpp:56) by : ACE_Task_Base::svc_run(void*) (in /usr/lib/libACE-6.0.3.so) by : ACE_Thread_Adapter::invoke_i() (in /usr/lib/libACE-6.0.3.so) by : ACE_Thread_Adapter::invoke() (in /usr/lib/libACE-6.0.3.so) by : start_thread (pthread_create.c:311) by : clone (clone.S:113) Address 0x4039011 is not stack'd, malloc'd or (recently) free'd Uninitialised value was created by a stack allocation at: BuilderThread::svc() (ContinentBuilder.cpp:30)
This commit is contained in:
1 parent
b1ed66b52d
commit
6f63d430b0
3 files changed
+14
-4
No files matched your search
@@ -58,6 +58,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
MmapTileHeader header;
|
||||
Utils::InitializeMmapTileHeader(header);
|
||||
header.size = builder.DataSize;
|
||||
fwrite(&header, sizeof(MmapTileHeader), 1, f);
|
||||
fwrite(nav, sizeof(unsigned char), builder.DataSize, f);
|
||||
@@ -149,6 +150,7 @@ void ContinentBuilder::Build()
|
||||
}
|
||||
|
||||
MmapTileHeader mheader;
|
||||
Utils::InitializeMmapTileHeader(mheader);
|
||||
mheader.size = builder->DataSize;
|
||||
fwrite(&mheader, sizeof(MmapTileHeader), 1, f);
|
||||
fwrite(nav, sizeof(unsigned char), builder->DataSize, f);
|
||||
|
||||
@@ -455,3 +455,13 @@ WMOGroupHeader WMOGroupHeader::Read(Stream* stream)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Utils::InitializeMmapTileHeader(MmapTileHeader& header)
|
||||
{
|
||||
memset(&header, 0, sizeof(MmapTileHeader));
|
||||
header.mmapMagic = MMAP_MAGIC;
|
||||
header.dtVersion = DT_NAVMESH_VERSION;
|
||||
header.mmapVersion = MMAP_VERSION;
|
||||
header.size = 0;
|
||||
header.usesLiquids = true;
|
||||
}
|
||||
@@ -344,10 +344,7 @@ struct MmapTileHeader
|
||||
uint32 dtVersion;
|
||||
uint32 mmapVersion;
|
||||
uint32 size;
|
||||
bool usesLiquids;
|
||||
|
||||
MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION),
|
||||
mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) {}
|
||||
bool usesLiquids : 1;
|
||||
};
|
||||
|
||||
class Utils
|
||||
@@ -386,5 +383,6 @@ public:
|
||||
static Vector3 TransformDoodadVertex(const IDefinition& def, Vector3 vec, bool translate = true);
|
||||
static Vector3 VectorTransform(const Vector3& vec, const G3D::Matrix4& matrix, bool normal = false);
|
||||
static Vector3 TransformWmoDoodad(const DoodadInstance& inst, const WorldModelDefinition& root, Vector3& vec, bool translate = true);
|
||||
static void InitializeMmapTileHeader(MmapTileHeader& header);
|
||||
};
|
||||
#endif
|
||||
Reference in new issue
Block a user