mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-18 10:31:42 +00:00
Ensure file is closed whenever MD2 reading errors happen
This commit is contained in:
parent
b00c680437
commit
05860b2fa1
1 changed files with 7 additions and 0 deletions
|
@ -313,6 +313,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
{ \
|
||||
CONS_Alert(CONS_ERROR, "md2_readModel: %s has too many " msgname " (# found: %d, maximum: %d)\n", filename, field, max); \
|
||||
md2_freeModel (model); \
|
||||
fclose(file); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
|
@ -334,6 +335,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(model->skins, sizeof (md2_skin_t), model->header.numSkins, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -347,6 +349,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(model->texCoords, sizeof (md2_textureCoordinate_t), model->header.numTexCoords, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -360,6 +363,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(model->triangles, sizeof (md2_triangle_t), model->header.numTriangles, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -372,6 +376,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
if (!model->frames)
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -385,6 +390,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(frame, 1, model->header.frameSize, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -410,6 +416,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(model->glCommandBuffer, sizeof (INT32), model->header.numGlCommands, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue