Merge pull request #2290 from assimp/Coverity-findings
fix finding: possible override.pull/2291/head
commit
0011c3b1aa
|
@ -124,22 +124,28 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
|
|||
file.read(reinterpret_cast<char*>(imageContent), imageSize);
|
||||
|
||||
// Enlarging the textures table
|
||||
auto textureId = pScene->mNumTextures++;
|
||||
unsigned int textureId = pScene->mNumTextures++;
|
||||
auto oldTextures = pScene->mTextures;
|
||||
pScene->mTextures = new aiTexture*[pScene->mNumTextures];
|
||||
memmove(pScene->mTextures, oldTextures, sizeof(aiTexture*) * (pScene->mNumTextures - 1u));
|
||||
::memmove(pScene->mTextures, oldTextures, sizeof(aiTexture*) * (pScene->mNumTextures - 1u));
|
||||
|
||||
// Add the new texture
|
||||
auto pTexture = new aiTexture();
|
||||
auto pTexture = new aiTexture;
|
||||
pTexture->mHeight = 0; // Means that this is still compressed
|
||||
pTexture->mWidth = static_cast<uint32_t>(imageSize);
|
||||
pTexture->pcData = imageContent;
|
||||
|
||||
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());
|
||||
if (extension == "jpeg") {
|
||||
extension = "jpg";
|
||||
}
|
||||
|
||||
size_t len = extension.size();
|
||||
if (len > HINTMAXTEXTURELEN -1 ) {
|
||||
len = HINTMAXTEXTURELEN - 1;
|
||||
}
|
||||
::strncpy(pTexture->achFormatHint, extension.c_str(), len);
|
||||
pScene->mTextures[textureId] = pTexture;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -400,6 +400,7 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel,
|
|||
if (nullptr != m_pCurrentFace) {
|
||||
m_pCurrentFace->mNumIndices = 3;
|
||||
m_pCurrentFace->mIndices = new unsigned int[3];
|
||||
m_pCurrentFace->mIndices[ idx ] = vertIdx;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,9 +410,7 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel,
|
|||
pMesh->mTextureCoords[ 0 ][ vertIdx ].Set( pVertex->vTexCoord.x, pVertex->vTexCoord.y, 0.0f );
|
||||
pMesh->mTextureCoords[ 1 ][ vertIdx ].Set( pVertex->vLightmap.x, pVertex->vLightmap.y, 0.0f );
|
||||
|
||||
m_pCurrentFace->mIndices[ idx ] = vertIdx;
|
||||
vertIdx++;
|
||||
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue