Bugfix #21212: Segfault when object.add_vertex_to_group() called with invalid vertex...
authorJoshua Leung <aligorith@gmail.com>
Mon, 5 Apr 2010 07:16:22 +0000 (07:16 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 5 Apr 2010 07:16:22 +0000 (07:16 +0000)
Safety checks are now performed before indexing into the dvert array obtained.

source/blender/editors/object/object_vgroup.c

index 6c9b45a63cd32deb095906c6bb3b0486910f277d..b086c47d6a667e66bb136ae48d0256e854c041b0 100644 (file)
@@ -284,7 +284,11 @@ void ED_vgroup_nr_vert_add(Object *ob, int def_nr, int vertnum, float weight, in
        if(dv==NULL)
                return;
        
-       dv+= vertnum;
+       /* check that vertnum is valid before trying to get the relevant dvert */
+       if ((vertnum < 0) || (vertnum >= tot))
+               return;
+       else
+               dv += vertnum;
 
        /* Lets first check to see if this vert is
         * already in the weight group -- if so