From 7a30c8bb4b70f42cc268b4b3a75dab5b414146c4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 24 Jul 2009 17:53:53 +0200 Subject: python/generic.h: Do not deallocate the temporary bytes object in PyUnicode_AsString. --- python/generic.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'python') diff --git a/python/generic.h b/python/generic.h index d7f121ce..75520914 100644 --- a/python/generic.h +++ b/python/generic.h @@ -79,11 +79,7 @@ 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); - if (!bytes) - return 0; - const char *result = PyBytes_AS_STRING(bytes); - Py_DECREF(bytes); - return result; + return bytes ? PyBytes_AS_STRING(bytes) : 0; } // Convert any type of string based object to a const char. -- cgit v1.2.3