Procházet zdrojové kódy

Merge branch 'master' into ihsinme-patch-210

Kim Kulling před 4 roky
rodič
revize
a9705e346a

+ 1 - 2
code/AssetLib/AC/ACLoader.h

@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
 
 Copyright (c) 2006-2020, assimp team
 
-
 All rights reserved.
 
 Redistribution and use of this software in source and binary forms,
@@ -117,7 +116,7 @@ public:
             Mask = 0xf,
         };
 
-        inline constexpr uint8_t GetType() const { return (flags & Mask); }
+        inline const uint8_t GetType() const { return (flags & Mask); }
     };
 
     // Represents an AC3D object

+ 11 - 11
code/AssetLib/glTF2/glTF2Asset.inl

@@ -560,18 +560,17 @@ inline void BufferView::Read(Value &obj, Asset &r) {
         buffer = r.buffers.Retrieve(bufferVal->GetUint());
     }
 
+    if (!buffer) {
+        throw DeadlyImportError("GLTF: Buffer view without valid buffer.");
+    }
+
     byteOffset = MemberOrDefault(obj, "byteOffset", size_t(0));
     byteLength = MemberOrDefault(obj, "byteLength", size_t(0));
     byteStride = MemberOrDefault(obj, "byteStride", 0u);
 
     // Check length
     if ((byteOffset + byteLength) > buffer->byteLength) {
-        const uint8_t val_size = 64;
-
-        char val[val_size];
-
-        ai_snprintf(val, val_size, "%llu, %llu", (unsigned long long)byteOffset, (unsigned long long)byteLength);
-        throw DeadlyImportError("GLTF: Buffer view with offset/length (", val, ") is out of range.");
+        throw DeadlyImportError("GLTF: Buffer view with offset/length (", byteOffset, "/", byteLength, ") is out of range.");
     }
 }
 
@@ -649,13 +648,14 @@ inline void Accessor::Read(Value &obj, Asset &r) {
     if (bufferView) {
         // Check length
         unsigned long long byteLength = (unsigned long long)GetBytesPerComponent() * (unsigned long long)count;
-        if ((byteOffset + byteLength) > bufferView->byteLength || (bufferView->byteOffset + byteOffset + byteLength) > bufferView->buffer->byteLength) {
-            const uint8_t val_size = 64;
 
-            char val[val_size];
+        // handle integer overflow
+        if (byteLength < count) {
+            throw DeadlyImportError("GLTF: Accessor with offset/count (", byteOffset, "/", count, ") is out of range.");
+        }
 
-            ai_snprintf(val, val_size, "%llu, %llu", (unsigned long long)byteOffset, (unsigned long long)byteLength);
-            throw DeadlyImportError("GLTF: Accessor with offset/length (", val, ") is out of range.");
+        if ((byteOffset + byteLength) > bufferView->byteLength || (bufferView->byteOffset + byteOffset + byteLength) > bufferView->buffer->byteLength) {
+            throw DeadlyImportError("GLTF: Accessor with offset/length (", byteOffset, "/", byteLength, ") is out of range.");
         }
     }
 

+ 0 - 4
include/assimp/StringComparison.h

@@ -145,11 +145,7 @@ int ASSIMP_stricmp(const char *s1, const char *s2) {
 #if (defined _MSC_VER)
 
     return ::_stricmp(s1, s2);
-#elif defined(__GNUC__)
-
-    return ::strcasecmp(s1, s2);
 #else
-
     char c1, c2;
     do {
         c1 = tolower(*s1++);