From d205bc3059202b93550812eb72d92ad8ceaff47c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 9 Sep 2016 10:55:22 +0200 Subject: [PATCH] Fix/Workaround T49297: Crash related to custom data draw (Blender with ASAN) Root of the issue is that active render index became wrong. This is the actual thing to be fixed, but as usual this is quite tricky to reproduce. Since such bad situation might have happened more and fix isn't really difficult or intruisive let's avoid crash for now. Can be revisited once we figure out root of the issue. Nice for 2.78 release. --- source/blender/blenkernel/intern/DerivedMesh.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 5f759c61bcb..8168817491f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -3474,13 +3474,17 @@ void DM_calc_loop_tangents( /* Update active layer index */ uv_index = CustomData_get_layer_index_n(&dm->loopData, CD_MLOOPUV, act_uv_n); - tan_index = CustomData_get_named_layer_index(&dm->loopData, CD_TANGENT, dm->loopData.layers[uv_index].name); - CustomData_set_layer_active_index(&dm->loopData, CD_TANGENT, tan_index); + if (uv_index != -1) { + tan_index = CustomData_get_named_layer_index(&dm->loopData, CD_TANGENT, dm->loopData.layers[uv_index].name); + CustomData_set_layer_active_index(&dm->loopData, CD_TANGENT, tan_index); + } /* Update render layer index */ uv_index = CustomData_get_layer_index_n(&dm->loopData, CD_MLOOPUV, ren_uv_n); - tan_index = CustomData_get_named_layer_index(&dm->loopData, CD_TANGENT, dm->loopData.layers[uv_index].name); - CustomData_set_layer_render_index(&dm->loopData, CD_TANGENT, tan_index); + if (uv_index != -1) { + tan_index = CustomData_get_named_layer_index(&dm->loopData, CD_TANGENT, dm->loopData.layers[uv_index].name); + CustomData_set_layer_render_index(&dm->loopData, CD_TANGENT, tan_index); + } } }