diff options
| author | mattip <matti.picus@gmail.com> | 2018-09-16 22:45:32 +0300 |
|---|---|---|
| committer | Charles Harris <charlesr.harris@gmail.com> | 2018-09-18 15:41:34 -0600 |
| commit | 519e0dabe281a18ba95ce6cfefe1b9f779cac766 (patch) | |
| tree | 486a4c9d0536a05f55ce88ef80b9d7c1d04b5bcc | |
| parent | 91d1b6374135ab4a825c6f7d7f20c8bd27afb3df (diff) | |
| download | numpy-519e0dabe281a18ba95ce6cfefe1b9f779cac766.tar.gz | |
BUG: fix refcount leak in PyArray_AdaptFlexibleDType
| -rw-r--r-- | numpy/core/src/multiarray/convert_datatype.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c index 0d79f294c..2e3ead2c3 100644 --- a/numpy/core/src/multiarray/convert_datatype.c +++ b/numpy/core/src/multiarray/convert_datatype.c @@ -149,11 +149,6 @@ PyArray_AdaptFlexibleDType(PyObject *data_obj, PyArray_Descr *data_dtype, { PyArray_DatetimeMetaData *meta; int flex_type_num; - PyArrayObject *arr = NULL; - PyArray_Descr *dtype = NULL; - int ndim = 0; - npy_intp dims[NPY_MAXDIMS]; - int result; if (*flex_dtype == NULL) { if (!PyErr_Occurred()) { @@ -168,7 +163,7 @@ PyArray_AdaptFlexibleDType(PyObject *data_obj, PyArray_Descr *data_dtype, /* Flexible types with expandable size */ if (PyDataType_ISUNSIZED(*flex_dtype)) { - /* First replace the flex dtype */ + /* First replace the flex_dtype */ PyArray_DESCR_REPLACE(*flex_dtype); if (*flex_dtype == NULL) { return; @@ -259,6 +254,10 @@ PyArray_AdaptFlexibleDType(PyObject *data_obj, PyArray_Descr *data_dtype, * GetArrayParamsFromObject won't iterate over * array. */ + PyArray_Descr *dtype = NULL; + PyArrayObject *arr = NULL; + int result, ndim = 0; + npy_intp dims[NPY_MAXDIMS]; list = PyArray_ToList((PyArrayObject *)data_obj); result = PyArray_GetArrayParamsFromObject( list, @@ -273,6 +272,8 @@ PyArray_AdaptFlexibleDType(PyObject *data_obj, PyArray_Descr *data_dtype, size = dtype->elsize; } } + Py_XDECREF(dtype); + Py_XDECREF(arr); Py_DECREF(list); } else if (PyArray_IsPythonScalar(data_obj)) { |
