diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index b06371a..e7d7fde 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -174,6 +174,11 @@ _mogrify(PyObject *var, PyObject *fmt, cursorObject *curs, PyObject **new) if it was added to the dictionary directly; good */ Py_XDECREF(value); } + else { + /* well, we found the value in 'n' but we've already + called PyObject_GetItem, so we have to decrement */ + Py_XDECREF(value); + } Py_DECREF(key); /* key has the original refcnt now */ Dprintf("_mogrify: after value refcnt: " FORMAT_CODE_PY_SSIZE_T, Py_REFCNT(value));