Re: pl/python tracebacks

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: pl/python tracebacks
Дата
Msg-id 1298551735.4783.4.camel@vanquo.pezone.net
обсуждение исходный текст
Ответ на Re: pl/python tracebacks  (Jan Urbański <wulczer@wulczer.org>)
Список pgsql-hackers
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.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: Invitation to Cluster Hackers meeting at pgCon
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: Sync Rep v17