Browse Source

Add a check for the resule of a dynamic cast.

Kim Kulling 6 năm trước cách đây
mục cha
commit
f5e94a2840
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      code/BlenderCustomData.cpp

+ 5 - 1
code/BlenderCustomData.cpp

@@ -28,7 +28,11 @@ namespace Assimp {
 
 #define IMPL_STRUCT_READ(ty)                                                    \
         bool read##ty(ElemBase *v, const size_t cnt, const FileDatabase &db) {  \
-            return read<ty>(db.dna[#ty], dynamic_cast<ty *>(v), cnt, db);       \
+        ty *ptr = dynamic_cast<ty*>(v);                                         \
+        if (nullptr == ptr) {                                                   \
+            return false;                                                       \
+        }                                                                       \
+        return read<ty>(db.dna[#ty], ptr, cnt, db);                             \
         }
 
 #define IMPL_STRUCT_CREATE(ty)                                                  \