diff options
author | Campbell Barton <campbell@blender.org> | 2022-01-20 03:29:32 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-01-20 03:59:20 +0300 |
commit | e3f9d9b206e60f61c80abc6b162f60c6fdcfdc6e (patch) | |
tree | 9aa1ec917d777f957b8925c90b899407b2b84933 /source/blender/blenkernel | |
parent | b7fe27314b25a7220a1cc5d5bc023d8776f55d9e (diff) |
Cleanup: quiet ASAN warnings for divide by zero & NULL memcpy args
No functional changes as the inf value was never used &
memcpy args were only NULL when the size to copy was zero.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_merge.c | 16 |
2 files changed, 18 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index ff8c05110b8..5704ef6e42f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1356,9 +1356,12 @@ static void ease_handle_axis(const float deriv1[3], const float deriv2[3], float copy_v3_v3(r_axis, deriv1); - float len1 = len_squared_v3(deriv1), len2 = len_squared_v3(deriv2); - float ratio = len1 / len2; - + const float len2 = len_squared_v3(deriv2); + if (UNLIKELY(len2 == 0.0f)) { + return; + } + const float len1 = len_squared_v3(deriv1); + const float ratio = len1 / len2; if (ratio < gap * gap) { madd_v3_v3fl(r_axis, deriv2, gap - sqrtf(ratio)); } diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c index 0115a70a52a..134a1344f83 100644 --- a/source/blender/blenkernel/intern/mesh_merge.c +++ b/source/blender/blenkernel/intern/mesh_merge.c @@ -615,10 +615,18 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, } /* Copy over data. #CustomData_add_layer can do this, need to look it up. */ - memcpy(result->mvert, mvert, sizeof(MVert) * STACK_SIZE(mvert)); - memcpy(result->medge, medge, sizeof(MEdge) * STACK_SIZE(medge)); - memcpy(result->mloop, mloop, sizeof(MLoop) * STACK_SIZE(mloop)); - memcpy(result->mpoly, mpoly, sizeof(MPoly) * STACK_SIZE(mpoly)); + if (STACK_SIZE(mvert)) { + memcpy(result->mvert, mvert, sizeof(MVert) * STACK_SIZE(mvert)); + } + if (STACK_SIZE(medge)) { + memcpy(result->medge, medge, sizeof(MEdge) * STACK_SIZE(medge)); + } + if (STACK_SIZE(mloop)) { + memcpy(result->mloop, mloop, sizeof(MLoop) * STACK_SIZE(mloop)); + } + if (STACK_SIZE(mpoly)) { + memcpy(result->mpoly, mpoly, sizeof(MPoly) * STACK_SIZE(mpoly)); + } MEM_freeN(mvert); MEM_freeN(medge); |