Browse Source

Avoid undefined-shift in Assimp::ASE::Parser::ParseLV4MeshFace.

Kim Kulling 2 years ago
parent
commit
81f85a6f93
2 changed files with 10 additions and 7 deletions
  1. 7 1
      code/AssetLib/ASE/ASEParser.cpp
  2. 3 6
      code/AssetLib/ASE/ASEParser.h

+ 7 - 1
code/AssetLib/ASE/ASEParser.cpp

@@ -1774,7 +1774,13 @@ void Parser::ParseLV4MeshFace(ASE::Face &out) {
         // FIX: There needn't always be a value, sad but true
         while (true) {
             if (*filePtr < '9' && *filePtr >= '0') {
-                out.iSmoothGroup |= (1 << strtoul10(filePtr, &filePtr));
+                uint32_t value = strtoul10(filePtr, &filePtr);
+                if (value < 32) {
+                    out.iSmoothGroup |= (1 << strtoul10(filePtr, &filePtr));
+                } else {
+                    const std::string message = std::string("Unable to set smooth group, value with ") + ai_to_string(value) + std::string(" out of range");
+                    LogWarning(message.c_str());
+                }
             }
             SkipSpaces(&filePtr);
             if (',' != *filePtr) {

+ 3 - 6
code/AssetLib/ASE/ASEParser.h

@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2022, assimp team
 
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -385,12 +384,10 @@ struct Dummy : public BaseNode {
 /** \brief Class to parse ASE files
  */
 class Parser {
-private:
-    Parser() AI_NO_EXCEPT {
-        // empty
-    }
-
 public:
+    /// @brief No default constructor.
+    Parser() AI_NO_EXCEPT = delete
+
     // -------------------------------------------------------------------
     //! Construct a parser from a given input file which is
     //! guaranteed to be terminated with zero.