[Bf-blender-cvs] [6d011d0e27d] master: Fix: Cryptomatte load corrupt manifests.

Jeroen Bakker noreply at git.blender.org
Tue Mar 16 10:13:20 CET 2021


Commit: 6d011d0e27d79b9c9fc7570770f5af958706e63a
Author: Jeroen Bakker
Date:   Tue Mar 16 10:09:35 2021 +0100
Branches: master
https://developer.blender.org/rB6d011d0e27d79b9c9fc7570770f5af958706e63a

Fix: Cryptomatte load corrupt manifests.

Seems like one of the example files on the cryptomatte github is
malformed and blender crashes when loading that file. This change will
try to load as much as possible from the manifest so it can still be
used.

This has also been reported to cryptomatte project.

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

M	source/blender/blenkernel/intern/cryptomatte.cc
M	source/blender/blenkernel/intern/cryptomatte_test.cc

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

diff --git a/source/blender/blenkernel/intern/cryptomatte.cc b/source/blender/blenkernel/intern/cryptomatte.cc
index 74576b8bbbb..bc89fa85cea 100644
--- a/source/blender/blenkernel/intern/cryptomatte.cc
+++ b/source/blender/blenkernel/intern/cryptomatte.cc
@@ -410,6 +410,9 @@ static bool from_manifest(CryptomatteLayer &layer, blender::StringRefNull manife
       ref = ref.drop_prefix(quoted_name_len);
       ref = skip_whitespaces_(ref);
 
+      if (ref.is_empty()) {
+        return false;
+      }
       char colon = ref.front();
       if (colon != ':') {
         return false;
@@ -417,7 +420,7 @@ static bool from_manifest(CryptomatteLayer &layer, blender::StringRefNull manife
       ref = ref.drop_prefix(1);
       ref = skip_whitespaces_(ref);
 
-      if (ref.front() != '\"') {
+      if (ref.is_empty() || ref.front() != '\"') {
         return false;
       }
 
diff --git a/source/blender/blenkernel/intern/cryptomatte_test.cc b/source/blender/blenkernel/intern/cryptomatte_test.cc
index 7a86002cf6a..85ab7e43d22 100644
--- a/source/blender/blenkernel/intern/cryptomatte_test.cc
+++ b/source/blender/blenkernel/intern/cryptomatte_test.cc
@@ -173,4 +173,14 @@ TEST(cryptomatte, session_from_stamp_data)
   RE_FreeRenderResult(render_result2);
 }
 
+/**
+ * Test method that contains known malformed manifests and makes sure that these can be parsed as
+ * best as possible. */
+TEST(cryptomatte, parsing_malformed_manifests)
+{
+  /* Manifest from multilayer.exr in the cryptomatte git-repository. */
+  test_cryptomatte_manifest(
+      R"({"/obj/instance1:instances:0":"0d54c6cc","/obj/instance1:instances:1":"293d9340","/obj/instance1:instances:110":"ccb9e1f2","/obj/instance1:instances:111":"f8dd3a48","/obj/instance1:instances:112":"a99e07a8","/obj/instance1:instances:113":"e75599a4","/obj/instance1:instances:114":"794200f3","/obj/instance1:instances:115":"2a3a1728","/obj/instance1:instances:116":"478544a1","/obj/instance1:instances:117":"b2bd969a","/obj/instance1:instances:10":"3a0c8681","/obj/instance1:instances [...]
+      R"({"\/obj\/box:polygons:1":"9d416418","\/obj\/instance1:instances:0":"0d54c6cc","\/obj\/instance1:instances:1":"293d9340","\/obj\/instance1:instances:10":"3a0c8681","\/obj\/instance1:instances:100":"2dcd2966","\/obj\/instance1:instances:101":"9331cd82","\/obj\/instance1:instances:102":"df50fccb","\/obj\/instance1:instances:103":"97f8590d","\/obj\/instance1:instances:104":"bbcd220d","\/obj\/instance1:instances:105":"4ae06139","\/obj\/instance1:instances:106":"8873d5ea","\/obj\/inst [...]
+}
 }  // namespace blender::bke::cryptomatte::tests



More information about the Bf-blender-cvs mailing list