diff options
author | Neil Conway <neilc@samurai.com> | 2006-02-20 20:10:37 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2006-02-20 20:10:37 +0000 |
commit | 45594a685928065ca8964e4fd80e361d2892dc34 (patch) | |
tree | b987ee6f6c0a529c27b19cc972b3a84291a3c199 | |
parent | dde945729477c90324d22131353956a4164ad104 (diff) | |
download | postgresql-45594a685928065ca8964e4fd80e361d2892dc34.tar.gz postgresql-45594a685928065ca8964e4fd80e361d2892dc34.zip |
Fix three Python reference leaks in PLy_traceback(). This would result
in leaking memory when invoking a PL/Python procedure that raises an
exception. Unfortunately this still leaks memory, but at least the
largest leak has been plugged.
This patch also fixes a reference counting mistake in PLy_modify_tuple()
for 8.0, 8.1 and HEAD: we don't actually own a reference to `platt', so
we shouldn't Py_DECREF() it.
-rw-r--r-- | src/pl/plpython/plpython.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index 2632e93493b..2df1ef39893 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -29,7 +29,7 @@ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.70 2006/01/10 00:33:12 neilc Exp $ + * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.71 2006/02/20 20:10:37 neilc Exp $ * ********************************************************************* */ @@ -543,7 +543,6 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata, { Py_XDECREF(plntup); Py_XDECREF(plkeys); - Py_XDECREF(platt); Py_XDECREF(plval); Py_XDECREF(plstr); @@ -1068,7 +1067,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, } /* - * now get information required for input conversion of the procedures + * now get information required for input conversion of the procedure's * arguments. */ proc->nargs = fcinfo->nargs; @@ -2516,6 +2515,7 @@ PLy_traceback(int *xlevel) } PyErr_NormalizeException(&e, &v, &tb); + Py_XDECREF(tb); eob = PyObject_Str(e); if (v && ((vob = PyObject_Str(v)) != NULL)) @@ -2534,9 +2534,10 @@ PLy_traceback(int *xlevel) Py_DECREF(eob); Py_XDECREF(vob); + Py_XDECREF(v); /* - * intuit an appropriate error level for based on the exception type + * intuit an appropriate error level based on the exception type */ if (PLy_exc_error && PyErr_GivenExceptionMatches(e, PLy_exc_error)) *xlevel = ERROR; @@ -2545,6 +2546,7 @@ PLy_traceback(int *xlevel) else *xlevel = ERROR; + Py_DECREF(e); return xstr; } |