From ebc062191ce19fad42aa68da3130cf2ca1bbb9aa Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 9 Mar 2023 16:31:07 +0100 Subject: [PATCH 1/3] LibOverride: Do not assert on invalid resync situation. Some checks here are really critical and should assert, but that one is more an indication that something is not going right, though data itself should still be mostly valid, so better warn the user with a LOG warning, than be silent in release builds, and crash in debug ones. --- source/blender/blenkernel/intern/lib_override.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc index 065ee010e72..56143273862 100644 --- a/source/blender/blenkernel/intern/lib_override.cc +++ b/source/blender/blenkernel/intern/lib_override.cc @@ -2525,8 +2525,16 @@ static void lib_override_library_main_resync_on_library_indirect_level( BLI_assert(id_resync_root_iter == id_resync_roots->list && id_resync_root_iter == id_resync_roots->last_node); } - BLI_assert(!lib_override_resync_tagging_finalize_recurse( - bmain, id_resync_root, id_roots, library_indirect_level, true)); + if (lib_override_resync_tagging_finalize_recurse( + bmain, id_resync_root, id_roots, library_indirect_level, true)) { + CLOG_WARN(&LOG, + "Resync root ID still has ancestors tagged for resync, this should not happen " + "at this point." + "\n\tRoot ID: %s" + "\n\tResync root ID: %s", + id_root->name, + id_resync_root->name); + } } BLI_ghashIterator_step(id_roots_iter); } From 15dd622a63cc3292d69bb9d062dea363fc45293b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 9 Mar 2023 16:34:27 +0100 Subject: [PATCH 2/3] Fix (unreported) crash in clnors with empty mesh. Do not try to allocate zero-size memory from memarena. --- source/blender/blenkernel/intern/mesh_normals.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index c83de7a843a..acd3460540d 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -494,10 +494,16 @@ void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr, lnors_spacearr->mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); } mem = lnors_spacearr->mem; - lnors_spacearr->lspacearr = (MLoopNorSpace **)BLI_memarena_calloc( - mem, sizeof(MLoopNorSpace *) * size_t(numLoops)); - lnors_spacearr->loops_pool = (LinkNode *)BLI_memarena_alloc( - mem, sizeof(LinkNode) * size_t(numLoops)); + if (numLoops > 0) { + lnors_spacearr->lspacearr = (MLoopNorSpace **)BLI_memarena_calloc( + mem, sizeof(MLoopNorSpace *) * size_t(numLoops)); + lnors_spacearr->loops_pool = (LinkNode *)BLI_memarena_alloc( + mem, sizeof(LinkNode) * size_t(numLoops)); + } + else { + lnors_spacearr->lspacearr = nullptr; + lnors_spacearr->loops_pool = nullptr; + } lnors_spacearr->spaces_num = 0; } From 8b2556e8d895c54012526b3eaa66eaf96cb7721c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 9 Mar 2023 16:36:56 +0100 Subject: [PATCH 3/3] Fix (unreported) crash in Array modifier in case of empty mesh. Return early the input mesh in case it is fully empty. --- source/blender/modifiers/intern/MOD_array.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/modifiers/intern/MOD_array.cc b/source/blender/modifiers/intern/MOD_array.cc index 1160a7ef65d..09387c98659 100644 --- a/source/blender/modifiers/intern/MOD_array.cc +++ b/source/blender/modifiers/intern/MOD_array.cc @@ -369,8 +369,12 @@ static void mesh_merge_transform(Mesh *result, static Mesh *arrayModifier_doArray(ArrayModifierData *amd, const ModifierEvalContext *ctx, - const Mesh *mesh) + Mesh *mesh) { + if (mesh->totvert == 0) { + return mesh; + } + MEdge *me; MLoop *ml; MPoly *mp;