diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2010-08-25 19:37:48 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2010-08-25 19:37:48 +0000 |
commit | 7499831ce6084227f714bc3430df417511e5ea46 (patch) | |
tree | c3a01c399b4682be92cc512964c83adc166ea373 | |
parent | 01faed3678de2096ae5f960363c468d695b52462 (diff) | |
download | postgresql-7499831ce6084227f714bc3430df417511e5ea46.tar.gz postgresql-7499831ce6084227f714bc3430df417511e5ea46.zip |
Catch null pointer returns from PyCObject_AsVoidPtr and PyCObject_FromVoidPtr
This is reproducibly possible in Python 2.7 if the user turned
PendingDeprecationWarning into an error, but it's theoretically also possible
in earlier versions in case of exceptional conditions.
backpatched to 8.0
-rw-r--r-- | src/pl/plpython/plpython.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index 889c84ab565..64640b625d5 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -1,7 +1,7 @@ /********************************************************************** * plpython.c - python as a procedural language for PostgreSQL * - * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.122.2.3 2010/04/30 19:15:51 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.122.2.4 2010/08/25 19:37:48 petere Exp $ * ********************************************************************* */ @@ -1135,6 +1135,8 @@ PLy_procedure_get(FunctionCallInfo fcinfo, Oid tgreloid) elog(FATAL, "expected a PyCObject, didn't get one"); proc = PyCObject_AsVoidPtr(plproc); + if (!proc) + PLy_elog(ERROR, "PyCObject_AsVoidPtr() failed"); if (proc->me != plproc) elog(FATAL, "proc->me != plproc"); /* did we find an up-to-date cache entry? */ @@ -1361,8 +1363,11 @@ PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key) PLy_procedure_compile(proc, procSource); pfree(procSource); + procSource = NULL; proc->me = PyCObject_FromVoidPtr(proc, NULL); + if (!proc->me) + PLy_elog(ERROR, "PyCObject_FromVoidPtr() failed"); PyDict_SetItemString(PLy_procedure_cache, key, proc->me); } PG_CATCH(); |