Use sizeof() instead of magic number for strncpy in ModelOutput::WriteOldModel

1008-fix
suve 2019-02-02 18:53:36 +01:00
parent 508e7529d2
commit 086e07168d
1 changed files with 4 additions and 1 deletions

View File

@ -328,7 +328,10 @@ void ModelOutput::WriteOldModel(const CModel& model, std::ostream &stream)
t.material.ambient = triangle.ambient;
t.material.diffuse = triangle.diffuse;
t.material.specular = triangle.specular;
strncpy(t.texName, triangle.tex1Name.c_str(), 20);
strncpy(t.texName, triangle.tex1Name.c_str(), sizeof(t.texName)-1);
t.texName[sizeof(t.texName)-1] = '\0';
t.min = 0.0f;
t.max = 1000000.0f;
t.state = ConvertToOldState(triangle);