Commit: 3014601f3be875496b7297954c48462a8a1a9ece
Author: Luca Rood
Date:   Thu Dec 22 02:11:59 2016 -0200
Branches: surface-deform-modifier
https://developer.blender.org/rB3014601f3be875496b7297954c48462a8a1a9ece

Fix out of bounds memory access in interp_weights_face_v3

interp_weights_face_v3 required a length four array for weights even when
calculating weights for a tri, otherwise, it would access unkown memory.
This fix allows a weight array of size three to be passed when only
calculating tri weights.

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

M       source/blender/blenlib/intern/math_geom.c

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

diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index 5ff8c90..7f9b33a 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2978,7 +2978,7 @@ void interp_weights_face_v3(float w[4], const float 
v1[3], const float v2[3], co
 {
        float w2[3];
 
-       w[0] = w[1] = w[2] = w[3] = 0.0f;
+       w[0] = w[1] = w[2] = 0.0f;
 
        /* first check for exact match */
        if (equals_v3v3(co, v1))
@@ -3005,6 +3005,7 @@ void interp_weights_face_v3(float w[4], const float 
v1[3], const float v2[3], co
 
                /* OpenGL seems to split this way, so we do too */
                if (v4) {
+                       w[3] = 0.0f;
                        degenerate = barycentric_weights(v1, v2, v4, co, n, w);
                        SWAP(float, w[2], w[3]);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to