2
0
Эх сурвалжийг харах

Fix coverity findings: fix possible out-of-bound access.

Kim Kulling 9 жил өмнө
parent
commit
2545dee58d
1 өөрчлөгдсөн 19 нэмэгдсэн , 21 устгасан
  1. 19 21
      code/ASEParser.cpp

+ 19 - 21
code/ASEParser.cpp

@@ -25,7 +25,6 @@ conditions are met:
   derived from this software without specific prior
   derived from this software without specific prior
   written permission of the assimp team.
   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
 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
@@ -1463,30 +1462,29 @@ void Parser::ParseLV2MeshBlock(ASE::Mesh& mesh)
                 continue;
                 continue;
             }
             }
             // another mesh UV channel ...
             // 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);
                 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 ...
                     // skip it ...
                     SkipSection();
                     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
             // mesh animation keyframe. Not supported
             if (TokenMatch(filePtr,"MESH_ANIMATION" ,14))
             if (TokenMatch(filePtr,"MESH_ANIMATION" ,14))