Fixed wrong refcnt on None.

This commit is contained in:
Federico Di Gregorio 2005-05-15 10:29:59 +00:00
parent 35c42310ec
commit e1e0b34343
2 changed files with 7 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2005-05-15 Federico Di Gregorio <fog@debian.org>
* psycopg/microprotocols.c (microprotocols_adapt): fixed memory
leak on None as suggested by gh (bug #16.)
2005-05-10 Federico Di Gregorio <fog@debian.org>
* lib/extras.py (DictRow): we now save a reference to the index

View File

@ -93,6 +93,7 @@ microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
if (PyObject_HasAttrString(proto, "__adapt__")) {
PyObject *adapted = PyObject_CallMethod(proto, "__adapt__", "O", obj);
if (adapted && adapted != Py_None) return adapted;
Py_XDECREF(adapted);
if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_TypeError))
return NULL;
}
@ -101,6 +102,7 @@ microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
if (PyObject_HasAttrString(obj, "__conform__")) {
PyObject *adapted = PyObject_CallMethod(obj, "__conform__","O", proto);
if (adapted && adapted != Py_None) return adapted;
Py_XDECREF(adapted);
if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_TypeError))
return NULL;
}