From f0c59697612922b9fb2563c8d43b7e8e1bda6425 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 30 Jan 2019 22:41:09 -0500 Subject: [PATCH] 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);