From 086e07168d3fbdac8ff806864dde3990cf208642 Mon Sep 17 00:00:00 2001 From: suve Date: Sat, 2 Feb 2019 18:53:36 +0100 Subject: [PATCH] Use sizeof() instead of magic number for strncpy in ModelOutput::WriteOldModel --- src/graphics/model/model_output.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/graphics/model/model_output.cpp b/src/graphics/model/model_output.cpp index 15ebeb75..ef94a3a5 100644 --- a/src/graphics/model/model_output.cpp +++ b/src/graphics/model/model_output.cpp @@ -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);