fix finding: possible override.

pull/2290/head
Kim Kulling 2018-12-31 12:16:20 +01:00
parent e09428c95b
commit 425a784b23
2 changed files with 8 additions and 2 deletions

View File

@ -138,7 +138,11 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
auto extension = path.substr(path.find_last_of('.') + 1u);
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
if (extension == "jpeg") extension = "jpg";
strcpy(pTexture->achFormatHint, extension.c_str());
size_t len = extension.size();
if (len > HINTMAXTEXTURELEN -1) {
len = HINTMAXTEXTURELEN - 1;
}
strncpy(pTexture->achFormatHint, extension.c_str(), len);
pScene->mTextures[textureId] = pTexture;

View File

@ -117,6 +117,8 @@ struct aiTexel
#include "./Compiler/poppack1.h"
#define HINTMAXTEXTURELEN 9
// --------------------------------------------------------------------------------
/** Helper structure to describe an embedded texture
*
@ -166,7 +168,7 @@ struct aiTexture {
* E.g. 'dds\\0', 'pcx\\0', 'jpg\\0'. All characters are lower-case.
* The fourth character will always be '\\0'.
*/
char achFormatHint[9];// 8 for string + 1 for terminator.
char achFormatHint[ HINTMAXTEXTURELEN ];// 8 for string + 1 for terminator.
/** Data of the texture.
*