From adfaafba9f45cea66a344d0d67916bee38b79ce2 Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 20 Jan 2019 10:18:09 +0200 Subject: BUG: double decref of dtype in failure codepath. Test and fix --- numpy/core/src/multiarray/ctors.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'numpy/core/src') diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 23a8dcea2..259ee9aac 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -2495,6 +2495,11 @@ PyArray_FromInterface(PyObject *origin) &PyArray_Type, dtype, n, dims, NULL, data, dataflags, NULL, base); + /* + * Ref to dtype was stolen by PyArray_NewFromDescrAndBase + * Prevent DECREFing dtype in fail codepath by setting to NULL + */ + dtype = NULL; if (ret == NULL) { goto fail; } -- cgit v1.2.1