diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-29 02:49:02 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-29 03:49:35 +0300 |
commit | 96f08bf9a8e0cfcbbc774c3c00c58d405e3dc55c (patch) | |
tree | 5c501fe681b6f4dcb22130eb3bce4ce263c578f3 /source/blender/python/mathutils | |
parent | 376e4c945ee862bb7cd7d22d677a5e59b8eeeb36 (diff) |
Fix leaks in mathutils PySequence_Fast usage
Diffstat (limited to 'source/blender/python/mathutils')
-rw-r--r-- | source/blender/python/mathutils/mathutils.c | 5 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.c | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 8b18a02a186..4a2d9cfe99b 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 aba1f909371..e0de5ddbdc0 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; } |