Selaa lähdekoodia

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

acgessler 12 vuotta sitten
vanhempi
commit
5a0b40db92
1 muutettua tiedostoa jossa 6 lisäystä ja 2 poistoa
  1. 6 2
      code/ColladaExporter.cpp

+ 6 - 2
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<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++;