From 5a0b40db92b05c357c1997fe5ea997ddffb99857 Mon Sep 17 00:00:00 2001 From: acgessler Date: Sun, 29 Sep 2013 21:56:32 +0200 Subject: [PATCH] ColladaExporter: fix assertion in ::isalnum() when a special character > 0x7f is present in material names. --- code/ColladaExporter.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 19f86fcf8..8fba4bf74 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -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 (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(*it) ) ) { *it = '_'; + } + } ReadMaterialSurface( materials[a].ambient, mat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT); if( !materials[a].ambient.texture.empty() ) numTextures++;