Skip to content

Commit

Permalink
Fix coverity findings: fix possible out-of-bound access.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkulling committed Aug 29, 2016
1 parent 238f14f commit 2545dee
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions code/ASEParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ conditions are met:
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Expand Down Expand Up @@ -1463,30 +1462,29 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
continue;
}
// another mesh UV channel ...
if (TokenMatch(filePtr,"MESH_MAPPINGCHANNEL" ,19))
{

unsigned int iIndex = 0;
if (TokenMatch(filePtr,"MESH_MAPPINGCHANNEL" ,19)) {
unsigned int iIndex( 0 );
ParseLV4MeshLong(iIndex);

if (iIndex < 2)
{
LogWarning("Mapping channel has an invalid index. Skipping UV channel");
// skip it ...
SkipSection();
}
if (iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS)
{
LogWarning("Too many UV channels specified. Skipping channel ..");
if ( 0 == iIndex ) {
LogWarning( "Mapping channel has an invalid index. Skipping UV channel" );
// skip it ...
SkipSection();
} else {
if ( iIndex < 2 ) {
LogWarning( "Mapping channel has an invalid index. Skipping UV channel" );
// skip it ...
SkipSection();
}
if ( iIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS ) {
LogWarning( "Too many UV channels specified. Skipping channel .." );
// skip it ...
SkipSection();
} else {
// parse the mapping channel
ParseLV3MappingChannel( iIndex - 1, mesh );
}
continue;
}
else
{
// parse the mapping channel
ParseLV3MappingChannel(iIndex-1,mesh);
}
continue;
}
// mesh animation keyframe. Not supported
if (TokenMatch(filePtr,"MESH_ANIMATION" ,14))
Expand Down

0 comments on commit 2545dee

Please sign in to comment.