From: Noel Power Date: Mon, 28 Jan 2019 15:23:48 +0000 (+0000) Subject: Fix mem leak with PyBytes_FromStringAndSize X-Git-Tag: ldb-1.6.1~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5dad03b83cd014277e2712ab04ad8a714d78a24c;p=thirdparty%2Fsamba.git Fix mem leak with PyBytes_FromStringAndSize Reviewed-by: Andrew Bartlett abartlet@samba.org --- diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c index d8f782f8d19..72981a22263 100644 --- a/source4/auth/gensec/pygensec.c +++ b/source4/auth/gensec/pygensec.c @@ -453,7 +453,7 @@ static PyObject *py_gensec_update(PyObject *self, PyObject *args) NTSTATUS status; TALLOC_CTX *mem_ctx; DATA_BLOB in, out; - PyObject *ret, *py_in; + PyObject *py_bytes, *result, *py_in; struct gensec_security *security = pytalloc_get_type(self, struct gensec_security); PyObject *finished_processing; @@ -477,7 +477,8 @@ static PyObject *py_gensec_update(PyObject *self, PyObject *args) talloc_free(mem_ctx); return NULL; } - ret = PyBytes_FromStringAndSize((const char *)out.data, out.length); + py_bytes = PyBytes_FromStringAndSize((const char *)out.data, + out.length); talloc_free(mem_ctx); if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { @@ -486,7 +487,9 @@ static PyObject *py_gensec_update(PyObject *self, PyObject *args) finished_processing = Py_True; } - return PyTuple_Pack(2, finished_processing, ret); + result = PyTuple_Pack(2, finished_processing, py_bytes); + Py_XDECREF(py_bytes); + return result; } static PyObject *py_gensec_wrap(PyObject *self, PyObject *args)