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:
authorCampbell Barton <ideasman42@gmail.com>2016-07-14 10:38:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-07-14 10:38:22 +0300
commitb00bc3cbc17b938a90f996b6a5206a876bf898a9 (patch)
treed384929951900dc4b74916fd0d97b6abb4914ead
parentf5e020a7a6ad6451fcaf075ae14f7014b8a4faea (diff)
PyAPI: fix leak linking library data
-rw-r--r--source/blender/python/intern/bpy_library_load.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index 9c417cfd221..7ceb99d5add 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -351,30 +351,30 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
/* loop */
Py_ssize_t size = PyList_GET_SIZE(ls);
Py_ssize_t i;
- PyObject *item;
- const char *item_str;
for (i = 0; i < size; i++) {
- item = PyList_GET_ITEM(ls, i);
- item_str = _PyUnicode_AsString(item);
+ PyObject *item_src = PyList_GET_ITEM(ls, i);
+#ifdef USE_RNA_DATABLOCKS
+ PyObject *item_dst = NULL;
+#endif
+ const char *item_idname = _PyUnicode_AsString(item_src);
- // printf(" %s\n", item_str);
+ // printf(" %s\n", item_idname);
- if (item_str) {
- ID *id = BLO_library_link_named_part(mainl, &(self->blo_handle), idcode, item_str);
+ if (item_idname) {
+ ID *id = BLO_library_link_named_part(mainl, &(self->blo_handle), idcode, item_idname);
if (id) {
#ifdef USE_RNA_DATABLOCKS
/* swap name for pointer to the id */
- Py_DECREF(item);
- item = PyCapsule_New((void *)id, NULL, NULL);
+ item_dst = PyCapsule_New((void *)id, NULL, NULL);
#endif
}
else {
- bpy_lib_exit_warn_idname(self, name_plural, item_str);
+ bpy_lib_exit_warn_idname(self, name_plural, item_idname);
/* just warn for now */
/* err = -1; */
#ifdef USE_RNA_DATABLOCKS
- item = Py_INCREF_RET(Py_None);
+ item_dst = Py_INCREF_RET(Py_None);
#endif
}
@@ -382,16 +382,20 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
}
else {
/* XXX, could complain about this */
- bpy_lib_exit_warn_type(self, item);
+ bpy_lib_exit_warn_type(self, item_src);
PyErr_Clear();
#ifdef USE_RNA_DATABLOCKS
- item = Py_INCREF_RET(Py_None);
+ item_dst = Py_INCREF_RET(Py_None);
#endif
}
#ifdef USE_RNA_DATABLOCKS
- PyList_SET_ITEM(ls, i, item);
+ if (item_dst) {
+ /* item_dst must be new or already incref'd */
+ Py_DECREF(item_src);
+ PyList_SET_ITEM(ls, i, item_dst);
+ }
#endif
}
}