On lör, 2011-02-12 at 10:07 +0100, Jan Urbański wrote: > > PLyUnicode_AsString(PyObject *unicode) > > { > > PyObject *o = PLyUnicode_Bytes(unicode); > > char *rv = pstrdup(PyBytes_AsString(o)); > > > > Py_XDECREF(o); > > return rv; > > } > > > > PyString_AsString is used all over the place without any pfrees. But > I > > have no Idea how that pstrdup() is getting freed if at all. > > > > Care to enlighten me ? > > Ooops, seems that this hack that's meant to improve compatibility with > Python3 makes it leak. I wonder is the pstrdup is necessary here,
The result of PyBytes_AsString(o) points into the internal storage of o, which is released (effectively freed) by the decref on the next line. So you'd better make a copy if you want to keep using it. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers