From ec0f1fa12be9f8a30d6cf86b9a60e9be55c7a068 Mon Sep 17 00:00:00 2001 From: Nelle Varoquaux Date: Fri, 1 Feb 2019 23:14:41 -0800 Subject: [PATCH] Backport PR #13333: Fix possible leak of return of PySequence_GetItem. --- src/_path_wrapper.cpp | 1 + src/py_adaptors.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/_path_wrapper.cpp b/src/_path_wrapper.cpp index 2fd90adb97f5..ab8c46c107e3 100644 --- a/src/_path_wrapper.cpp +++ b/src/_path_wrapper.cpp @@ -727,6 +727,7 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject * return NULL; } codes[i] = PyBytes_AsString(item); + Py_DECREF(item); if (codes[i] == NULL) { return NULL; } diff --git a/src/py_adaptors.h b/src/py_adaptors.h index d5714db2d8bf..bb11276ebee1 100644 --- a/src/py_adaptors.h +++ b/src/py_adaptors.h @@ -240,6 +240,7 @@ class PathGenerator throw py::exception(); } if (!convert_path(item, &path)) { + Py_DECREF(item); throw py::exception(); } Py_DECREF(item);