mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 15:22:20 +00:00
Ensure file is closed whenever MD2 reading errors happen
This commit is contained in:
parent
b150e842fc
commit
67a2922558
1 changed files with 7 additions and 0 deletions
|
@ -319,6 +319,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; \
|
||||
}
|
||||
|
||||
|
@ -340,6 +341,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;
|
||||
}
|
||||
}
|
||||
|
@ -353,6 +355,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;
|
||||
}
|
||||
}
|
||||
|
@ -366,6 +369,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;
|
||||
}
|
||||
}
|
||||
|
@ -378,6 +382,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
if (!model->frames)
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -391,6 +396,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(frame, 1, model->header.frameSize, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -416,6 +422,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