From 34db81a6dc9176e74beee656e4bc03971dc22430 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Mar 2012 11:10:11 +0000 Subject: [PATCH] fix for missing NULL check in bmesh.from_mesh(), bug [#30446] --- source/blender/python/bmesh/bmesh_py_api.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c index b6064c452fe..375e7cfae14 100644 --- a/source/blender/python/bmesh/bmesh_py_api.c +++ b/source/blender/python/bmesh/bmesh_py_api.c @@ -60,14 +60,19 @@ static PyObject *bpy_bm_from_mesh(PyObject *UNUSED(self), PyObject *value) { Mesh *me = PyC_RNA_AsPointer(value, "Mesh"); - /* temp! */ - if (!me->edit_btmesh) { - PyErr_SetString(PyExc_ValueError, - "Mesh is not in editmode"); + if (me) { + /* temp! */ + if (!me->edit_btmesh) { + PyErr_SetString(PyExc_ValueError, + "Mesh is not in editmode"); + return NULL; + } + + return BPy_BMesh_CreatePyObject(me->edit_btmesh->bm); + } + else { return NULL; } - - return BPy_BMesh_CreatePyObject(me->edit_btmesh->bm); } static struct PyMethodDef BPy_BM_methods[] = {