fix for crash in bmesh py api, was missing NULL checks for parsing sequences and...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 4 Mar 2012 02:09:02 +0000 (02:09 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 4 Mar 2012 02:09:02 +0000 (02:09 +0000)
source/blender/python/bmesh/bmesh_py_select.c
source/blender/python/bmesh/bmesh_py_types.c

index fd9f329f7c0267d69d1b43b2cbb02424e346f9a6..c5c66c0aaaa258777bdac896af1a5b5293dd15de 100644 (file)
@@ -65,7 +65,7 @@ static PyObject *bpy_bmeditselseq_active_get(BPy_BMEditSelSeq *self, void *UNUSE
 }
 
 static PyGetSetDef bpy_bmeditselseq_getseters[] = {
-    {(char *)"active", (getter)bpy_bmeditselseq_active_get, (setter)NULL, (char *)bpy_bmeditselseq_active_doc, (void *)BM_VERTS_OF_MESH},
+    {(char *)"active", (getter)bpy_bmeditselseq_active_get, (setter)NULL, (char *)bpy_bmeditselseq_active_doc, NULL},
     {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 
@@ -228,21 +228,21 @@ static int bpy_bmeditselseq_contains(BPy_BMEditSelSeq *self, PyObject *value)
 }
 
 static PySequenceMethods bpy_bmeditselseq_as_sequence = {
-    (lenfunc)bpy_bmeditselseq_length,                  /* sq_length */
+    (lenfunc)bpy_bmeditselseq_length,            /* sq_length */
     NULL,                                        /* sq_concat */
     NULL,                                        /* sq_repeat */
-    (ssizeargfunc)bpy_bmeditselseq_subscript_int,      /* sq_item */ /* Only set this so PySequence_Check() returns True */
+    (ssizeargfunc)bpy_bmeditselseq_subscript_int,/* sq_item */ /* Only set this so PySequence_Check() returns True */
     NULL,                                        /* sq_slice */
     (ssizeobjargproc)NULL,                       /* sq_ass_item */
     NULL,                                        /* *was* sq_ass_slice */
-    (objobjproc)bpy_bmeditselseq_contains,             /* sq_contains */
+    (objobjproc)bpy_bmeditselseq_contains,       /* sq_contains */
     (binaryfunc) NULL,                           /* sq_inplace_concat */
     (ssizeargfunc) NULL,                         /* sq_inplace_repeat */
 };
 
 static PyMappingMethods bpy_bmeditselseq_as_mapping = {
-    (lenfunc)bpy_bmeditselseq_length,                  /* mp_length */
-    (binaryfunc)bpy_bmeditselseq_subscript,            /* mp_subscript */
+    (lenfunc)bpy_bmeditselseq_length,            /* mp_length */
+    (binaryfunc)bpy_bmeditselseq_subscript,      /* mp_subscript */
     (objobjargproc)NULL,                         /* mp_ass_subscript */
 };
 
index 757f1f2ed90c6e296e12dc0703d7fefcf839af24..5dc4e94c98a02d1c03323aa05abddaca62b15ab1 100644 (file)
@@ -839,6 +839,10 @@ static PyObject *bpy_bmvert_copy_from_vert_interp(BPy_BMVert *self, PyObject *ar
                                                       &vert_seq_len, &BPy_BMVert_Type,
                                                       TRUE, TRUE, "BMVert.copy_from_vert_interp(...)");
 
+               if (vert_array == NULL) {
+                       return NULL;
+               }
+
                BM_data_interp_from_verts(bm, vert_array[0], vert_array[1], self->v, CLAMPIS(fac, 0.0f, 1.0f));
 
                PyMem_FREE(vert_array);
@@ -1279,6 +1283,10 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
                                                       &vert_seq_len, &BPy_BMVert_Type,
                                                       TRUE, TRUE, "edges.new(...)");
 
+               if (vert_array == NULL) {
+                       return NULL;
+               }
+               
                if (BM_edge_exists(vert_array[0], vert_array[1])) {
                        PyErr_SetString(PyExc_ValueError,
                                        "edges.new(): this edge exists");
@@ -1342,6 +1350,10 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
                                                       &vert_seq_len, &BPy_BMVert_Type,
                                                       TRUE, TRUE, "faces.new(...)");
 
+               if (vert_array == NULL) {
+                       return NULL;
+               }
+
                /* check if the face exists */
                if (BM_face_exists(bm, vert_array, vert_seq_len, NULL)) {
                        PyErr_SetString(PyExc_ValueError,
@@ -2600,7 +2612,7 @@ void *BPy_BMElem_PySeq_As_Array(BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_
 
                        if (Py_TYPE(item) != type) {
                                PyErr_Format(PyExc_TypeError,
-                                            "%s: expected '%.200', not '%.200s'",
+                                            "%s: expected '%.200s', not '%.200s'",
                                             error_prefix, type->tp_name, Py_TYPE(item)->tp_name);
                                goto err_cleanup;
                        }