From fda50625cd099b4e65b5e82c7c9a48af256b45fd Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 26 Mar 2021 09:08:24 +0100 Subject: Cryptomatte: Fix error loading incomplete metadata. When rendering with cycles at some point the manifest is trimmed. This leads to incomplete/corrupted metadata. This patch will make sure that the manifest parser doesn't crash. This solved the issue when the manifest is trimmed at the start of a hash. Eg '"Name":"'. --- source/blender/blenkernel/intern/cryptomatte.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenkernel/intern/cryptomatte.cc b/source/blender/blenkernel/intern/cryptomatte.cc index bc89fa85cea..99f0342e223 100644 --- a/source/blender/blenkernel/intern/cryptomatte.cc +++ b/source/blender/blenkernel/intern/cryptomatte.cc @@ -425,6 +425,9 @@ static bool from_manifest(CryptomatteLayer &layer, blender::StringRefNull manife } const int quoted_hash_len = quoted_string_len_(ref); + if (quoted_hash_len < 2) { + return false; + } const int hash_len = quoted_hash_len - 2; CryptomatteHash hash = CryptomatteHash::from_hex_encoded(ref.substr(1, hash_len)); ref = ref.drop_prefix(quoted_hash_len); -- cgit v1.2.3