Commit: 96f08bf9a8e0cfcbbc774c3c00c58d405e3dc55c
Author: Campbell Barton
Date: Wed Jul 29 09:49:02 2015 +1000
Branches: master
https://developer.blender.org/rB96f08bf9a8e0cfcbbc774c3c00c58d405e3dc55c
Fix leaks in mathutils PySequence_Fast usage
===================================================================
M source/blender/python/mathutils/mathutils.c
M source/blender/python/mathutils/mathutils_Matrix.c
===================================================================
diff --git a/source/blender/python/mathutils/mathutils.c
b/source/blender/python/mathutils/mathutils.c
index 8b18a02..4a2d9cf 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -70,12 +70,10 @@ static int mathutils_array_parse_fast(float *array,
"%.200s: sequence index %d expected a
number, "
"found '%.200s' type, ",
error_prefix, i, Py_TYPE(item)->tp_name);
- Py_DECREF(value_fast);
return -1;
}
} while (i);
- Py_XDECREF(value_fast);
return size;
}
@@ -182,6 +180,7 @@ int mathutils_array_parse(float *array, int array_min, int
array_max, PyObject *
}
size = mathutils_array_parse_fast(array, size, value_fast,
error_prefix);
+ Py_DECREF(value_fast);
}
if (size != -1) {
@@ -239,6 +238,7 @@ int mathutils_array_parse_alloc(float **array, int
array_min, PyObject *value, c
size = PySequence_Fast_GET_SIZE(value_fast);
if (size < array_min) {
+ Py_DECREF(value_fast);
PyErr_Format(PyExc_ValueError,
"%.200s: sequence size is %d, expected >
%d",
error_prefix, size, array_min);
@@ -248,6 +248,7 @@ int mathutils_array_parse_alloc(float **array, int
array_min, PyObject *value, c
*array = PyMem_Malloc(size * sizeof(float));
ret = mathutils_array_parse_fast(*array, size, value_fast,
error_prefix);
+ Py_DECREF(value_fast);
if (ret == -1) {
PyMem_Free(*array);
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c
b/source/blender/python/mathutils/mathutils_Matrix.c
index aba1f90..e0de5dd 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -2226,6 +2226,7 @@ static int Matrix_ass_slice(MatrixObject *self, int
begin, int end, PyObject *va
if (mathutils_array_parse(vec, self->num_col,
self->num_col, item,
"matrix[begin:end] = value
assignment") == -1)
{
+ Py_DECREF(value_fast);
return -1;
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs