summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pl/plpython/plpython.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index ab4f208677e..c9f1ee5f270 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.58.4.8 2008/07/28 18:45:18 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.58.4.9 2009/11/03 07:53:58 petere Exp $
*
*********************************************************************
*/
@@ -2411,9 +2411,9 @@ PLy_fatal(PyObject * self, PyObject * args)
static PyObject *
PLy_output(volatile int level, PyObject * self, PyObject * args)
{
- PyObject *so;
+ PyObject *volatile so;
char *volatile sv;
- MemoryContext oldcontext;
+ volatile MemoryContext oldcontext;
so = PyObject_Str(args);
if ((so == NULL) || ((sv = PyString_AsString(so)) == NULL))
@@ -2432,6 +2432,10 @@ PLy_output(volatile int level, PyObject * self, PyObject * args)
MemoryContextSwitchTo(oldcontext);
PLy_error_in_progress = CopyErrorData();
FlushErrorState();
+
+ PyErr_SetString(PLy_exc_error, sv);
+ /* Note: If sv came from PyString_AsString(), it points into
+ * storage owned by so. So free so after using sv. */
Py_XDECREF(so);
/*
@@ -2439,7 +2443,6 @@ PLy_output(volatile int level, PyObject * self, PyObject * args)
* control passes back to PLy_procedure_call, we check for PG
* exceptions and re-throw the error.
*/
- PyErr_SetString(PLy_exc_error, sv);
return NULL;
}
PG_END_TRY();