From a691dfaeed95528206863db49f00980413913afc Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 7 Dec 2010 15:05:07 +0100 Subject: python/generic.h: Fix a memory leak (leaking on every unicode string). --- python/generic.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/generic.h b/python/generic.h index 31c1bc2d..fc2a6c06 100644 --- a/python/generic.h +++ b/python/generic.h @@ -79,7 +79,9 @@ typedef int Py_ssize_t; static inline const char *PyUnicode_AsString(PyObject *op) { // Convert to bytes object, using the default encoding. - PyObject *bytes = PyUnicode_AsEncodedString(op,0,0); + // Use Python-internal API, there is no other way to do this + // without a memory leak. + PyObject *bytes = _PyUnicode_AsDefaultEncodedString(op, 0); return bytes ? PyBytes_AS_STRING(bytes) : 0; } -- cgit v1.2.3