sprintf: replace sprintf by snprintf.

pull/749/head
Kim Kulling 2016-01-04 20:24:51 +01:00
parent f4d3d15bbb
commit c9d00beab8
3 changed files with 8 additions and 8 deletions

View File

@ -379,7 +379,7 @@ struct Material
static int iCnt = 0;
char szTemp[128];
sprintf(szTemp,"UNNAMED_%i",iCnt++);
snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
mName = szTemp;
}
@ -435,7 +435,7 @@ struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
// Generate a default name for the mesh
char szTemp[128];
::sprintf(szTemp,"UNNAMED_%i",iCnt++);
::snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
mName = szTemp;
}
@ -495,7 +495,7 @@ struct Node
// Generate a default name for the node
char szTemp[128];
::sprintf(szTemp,"UNNAMED_%i",iCnt++);
::snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
mName = szTemp;
aRotationKeys.reserve (20);

View File

@ -211,7 +211,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
// Generate a default name for both the light source and the node
// FIXME - what's the right way to print a size_t? Is 'zu' universally available? stick with the safe version.
light->mName.length = ::sprintf(light->mName.data,"ACLight_%i",static_cast<unsigned int>(mLights->size())-1);
light->mName.length = ::snprintf(light->mName.data, MAXLEN, "ACLight_%i",static_cast<unsigned int>(mLights->size())-1);
obj.name = std::string( light->mName.data );
DefaultLogger::get()->debug("AC3D: Light source encountered");
@ -733,13 +733,13 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
switch (object.type)
{
case Object::Group:
node->mName.length = ::sprintf(node->mName.data,"ACGroup_%i",groups++);
node->mName.length = ::snprintf(node->mName.data, MAXLEN, "ACGroup_%i",groups++);
break;
case Object::Poly:
node->mName.length = ::sprintf(node->mName.data,"ACPoly_%i",polys++);
node->mName.length = ::snprintf(node->mName.data, MAXLEN, "ACPoly_%i",polys++);
break;
case Object::Light:
node->mName.length = ::sprintf(node->mName.data,"ACLight_%i",lights++);
node->mName.length = ::snprintf(node->mName.data, MAXLEN, "ACLight_%i",lights++);
break;
// there shouldn't be more than one world, but we don't care

View File

@ -377,7 +377,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
aiColor3D color(1.f,1.f,1.f);
aiString s;
::sprintf( s.data, MAXLEN, "mat%u_tx%u_",i,materials[i].tex );
::snprintf( s.data, MAXLEN, "mat%u_tx%u_",i,materials[i].tex );
// set the two-sided flag
if (materials[i].type == Unreal::MF_NORMAL_TS) {