Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 45594a6

Browse files
author
Neil Conway
committed
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.
1 parent dde9457 commit 45594a6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pl/plpython/plpython.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
3030
*
3131
* IDENTIFICATION
32-
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.70 2006/01/10 00:33:12 neilc Exp $
32+
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.71 2006/02/20 20:10:37 neilc Exp $
3333
*
3434
*********************************************************************
3535
*/
@@ -543,7 +543,6 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
543543
{
544544
Py_XDECREF(plntup);
545545
Py_XDECREF(plkeys);
546-
Py_XDECREF(platt);
547546
Py_XDECREF(plval);
548547
Py_XDECREF(plstr);
549548

@@ -1068,7 +1067,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
10681067
}
10691068

10701069
/*
1071-
* now get information required for input conversion of the procedures
1070+
* now get information required for input conversion of the procedure's
10721071
* arguments.
10731072
*/
10741073
proc->nargs = fcinfo->nargs;
@@ -2516,6 +2515,7 @@ PLy_traceback(int *xlevel)
25162515
}
25172516

25182517
PyErr_NormalizeException(&e, &v, &tb);
2518+
Py_XDECREF(tb);
25192519

25202520
eob = PyObject_Str(e);
25212521
if (v && ((vob = PyObject_Str(v)) != NULL))
@@ -2534,9 +2534,10 @@ PLy_traceback(int *xlevel)
25342534

25352535
Py_DECREF(eob);
25362536
Py_XDECREF(vob);
2537+
Py_XDECREF(v);
25372538

25382539
/*
2539-
* intuit an appropriate error level for based on the exception type
2540+
* intuit an appropriate error level based on the exception type
25402541
*/
25412542
if (PLy_exc_error && PyErr_GivenExceptionMatches(e, PLy_exc_error))
25422543
*xlevel = ERROR;
@@ -2545,6 +2546,7 @@ PLy_traceback(int *xlevel)
25452546
else
25462547
*xlevel = ERROR;
25472548

2549+
Py_DECREF(e);
25482550
return xstr;
25492551
}
25502552

0 commit comments

Comments
 (0)