ColladaExporter: fix assertion in ::isalnum() when a special character > 0x7f is present in material names.

pull/138/merge
acgessler 2013-09-29 21:56:32 +02:00
parent deeeaf5c05
commit 5a0b40db92
1 changed files with 6 additions and 2 deletions

View File

@ -235,9 +235,13 @@ void ColladaExporter::WriteMaterials()
if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS )
name = "mat";
materials[a].name = std::string( "m") + boost::lexical_cast<std::string> (a) + name.C_Str();
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it )
if( !isalnum( *it) )
for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) {
// isalnum on MSVC asserts for code points in [0,255]. Thus prevent unwanted promotion
// of char to signed int and take the unsigned char value.
if( !isalnum( static_cast<uint8_t>(*it) ) ) {
*it = '_';
}
}
ReadMaterialSurface( materials[a].ambient, mat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT);
if( !materials[a].ambient.texture.empty() ) numTextures++;