[Bf-blender-cvs] [d2eccca2375] usd-importer-T81257-merge: USD Import: read attributes null data guard.

makowalski noreply at git.blender.org
Wed Mar 10 03:02:24 CET 2021


Commit: d2eccca2375a1c464b22dd65bc32bc9699a617ee
Author: makowalski
Date:   Tue Mar 9 18:06:04 2021 -0500
Branches: usd-importer-T81257-merge
https://developer.blender.org/rBd2eccca2375a1c464b22dd65bc32bc9699a617ee

USD Import: read attributes null data guard.

Checking for null pointer to avoid crash when custom data
allocation fails.

===================================================================

M	source/blender/io/usd/intern/usd_reader_mesh.cc

===================================================================

diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index b5e0cac18cf..3daaa1c07a0 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -499,13 +499,22 @@ void USDMeshReader::read_attributes(Mesh *mesh,
       type_size = sizeof(pxr::GfVec3i);
       data = (void *)idata.cdata();
     }
+    else {
+      continue;
+    }
 
     void *cdata = CustomData_get_layer_named(cd, cd_type, name);
 
     if (!cdata) {
       cdata = CustomData_add_layer_named(cd, cd_type, CD_DEFAULT, NULL, num, name);
     }
-    memcpy(cdata, data, num * type_size);
+
+    if (cdata) {
+      memcpy(cdata, data, num * type_size);
+    }
+    else {
+      std::cerr << "WARNING: Couldn't add custom data layer " << name << std::endl;
+    }
   }
 }



More information about the Bf-blender-cvs mailing list