summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Conway2006-02-20 20:10:48 +0000
committerNeil Conway2006-02-20 20:10:48 +0000
commit11b347267294ab2f9db42440fc2be6035f59bf28 (patch)
tree08ed3ef7f6ae6169a757d2acf161c7dd96715cf4
parent0c853662bdd73ad7ffdcf9e87208b97679826119 (diff)
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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 5f485aa9e19..a2051534290 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.26.2.6 2003/09/17 18:40:11 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.26.2.7 2006/02/20 20:10:48 neilc Exp $
*
*********************************************************************
*/
@@ -1131,7 +1131,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, bool is_trigger,
}
/*
- * 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;
@@ -2855,6 +2855,7 @@ PLy_traceback(int *xlevel)
}
PyErr_NormalizeException(&e, &v, &tb);
+ Py_XDECREF(tb);
eob = PyObject_Str(e);
if ((v) && ((vob = PyObject_Str(v)) != NULL))
@@ -2867,9 +2868,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;
@@ -2878,6 +2880,7 @@ PLy_traceback(int *xlevel)
else
*xlevel = ERROR;
+ Py_DECREF(e);
leave();
return xstr;