diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-06 07:33:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-06 07:33:11 +0400 |
commit | 6a164c7f72e679985e78f92b635426db73a93022 (patch) | |
tree | a29da8882ba771df44fdb6b0808c9b05dc70c587 /source | |
parent | c4472bbab678cfc826fc40fe9272db38cbb6a1cd (diff) |
fix [#32779] Bmesh module: assigning to bm.select_mode crashes Blender if bmesh is empty
was missing set typecheck
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index a2521484c88..2b4dcf93b66 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -760,7 +760,6 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int *valu return 0; } -/* 'value' _must_ be a set type, error check before calling */ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix) { /* set of enum items, concatenate all values with OR */ @@ -771,6 +770,15 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, co Py_ssize_t hash = 0; PyObject *key; + PyC_ObSpit("", value); + + if (!PySet_Check(value)) { + PyErr_Format(PyExc_TypeError, + "%.200s expected a set, not %.200s", + error_prefix, Py_TYPE(value)->tp_name); + return -1; + } + *r_value = 0; while (_PySet_NextEntry(value, &pos, &key, &hash)) { @@ -778,7 +786,7 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, co if (param == NULL) { PyErr_Format(PyExc_TypeError, - "%.200s expected a string, not %.200s", + "%.200s set must contain strings, not %.200s", error_prefix, Py_TYPE(key)->tp_name); return -1; } |