check for null FILE pointer after trying to create the MESH file

This commit is contained in:
gered 2010-06-23 21:23:39 -04:00
parent e0996a381d
commit 5b7f26aeaa
2 changed files with 11 additions and 0 deletions

View file

@ -294,6 +294,8 @@ bool Md2::Load(const std::string &file)
bool Md2::ConvertToMesh(const std::string &file)
{
FILE *fp = fopen(file.c_str(), "wb");
if (fp == NULL)
return false;
fputs("MESH", fp);
unsigned char version = 1;

View file

@ -209,5 +209,14 @@ bool StaticModel::Load(const std::string &file, const std::string &texturePath)
bool StaticModel::ConvertToMesh(const std::string &file)
{
FILE *fp = fopen(file.c_str(), "wb");
if (fp == NULL)
return false;
fputs("MESH", fp);
unsigned char version = 1;
fwrite(&version, 1, 1, fp);
fclose(fp);
return true;
}