Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-02-18 18:55:32 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-02-18 19:16:33 +0300
commit1414c4496cc492320ec5076fe17cfb8e89df6a01 (patch)
tree67469bda78ffcfc656f96de9ed77635296efa800 /source/blender/python
parentb8ec2c95596fe9b9a0b4c3426640ba58eeeb2efb (diff)
ID Management Py API: Fix (unreported) crash in some cases.
Would crash when passing some kind of invalid parameters, e.g.: >>>D.user_map(key_types={'brush'})
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 5f18a64a8a2..72c808aa630 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -170,6 +170,8 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
PyObject *ret = NULL;
+ IDUserMapData data_cb = {NULL};
+
static const char *_keywords[] = {"subset", "key_types", "value_types", NULL};
static _PyArg_Parser _parser = {"|O$O!O!:user_map", _keywords, 0};
if (!_PyArg_ParseTupleAndKeywordsFast(
@@ -197,8 +199,6 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
}
}
- IDUserMapData data_cb = {NULL};
-
if (subset) {
PyObject *subset_fast = PySequence_Fast(subset, "user_map");
if (subset_fast == NULL) {
@@ -268,13 +268,15 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
ret = data_cb.user_map;
error:
- Py_XDECREF(data_cb.py_id_key_lookup_only);
+ if (data_cb.py_id_key_lookup_only != NULL) {
+ Py_XDECREF(data_cb.py_id_key_lookup_only);
+ }
- if (key_types_bitmap) {
+ if (key_types_bitmap != NULL) {
MEM_freeN(key_types_bitmap);
}
- if (val_types_bitmap) {
+ if (val_types_bitmap != NULL) {
MEM_freeN(val_types_bitmap);
}