added some checking for data chunks which have zero elements in the file being loaded (so we skip them, instead of new'ing an array with length == 0)
This commit is contained in:
parent
a0501481cc
commit
5fc89c88f7
|
@ -114,6 +114,8 @@ bool Ms3d::Load(const std::string &file)
|
|||
|
||||
// read material information
|
||||
fread(&m_numMaterials, 2, 1, fp);
|
||||
if (m_numMaterials > 0)
|
||||
{
|
||||
m_materials = new Ms3dMaterial[m_numMaterials];
|
||||
|
||||
for (int i = 0; i < m_numMaterials; ++i)
|
||||
|
@ -135,12 +137,15 @@ bool Ms3d::Load(const std::string &file)
|
|||
fread(&material->texture, 128, 1, fp);
|
||||
fread(&material->alpha, 128, 1, fp);
|
||||
}
|
||||
}
|
||||
|
||||
// read joints
|
||||
fread(&m_animationFps, 4, 1, fp);
|
||||
fread(&m_editorAnimationTime, 4, 1, fp);
|
||||
fread(&m_numFrames, 4, 1, fp);
|
||||
fread(&m_numJoints, 2, 1, fp);
|
||||
if (m_numJoints > 0)
|
||||
{
|
||||
m_joints = new Ms3dJoint[m_numJoints];
|
||||
|
||||
for (int i = 0; i < m_numJoints; ++i)
|
||||
|
@ -177,6 +182,7 @@ bool Ms3d::Load(const std::string &file)
|
|||
fread(&frame->param.z, 4, 1, fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
|
|
Reference in a new issue