git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 52ba9a5)
Catch null pointer returns from PyCObject_AsVoidPtr and PyCObject_FromVoidPtr
2010年8月25日 19:37:56 +0000 (19:37 +0000)
2010年8月25日 19:37:56 +0000 (19:37 +0000)
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


diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index e1a976ec6e5dd260362e5cb18916f8b877b5d984..0c4d0928e212b2c1a831c6b5512cf6def26d0cc2 100644 (file)
--- 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.148 2010年07月08日 19:00:11 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.149 2010年08月25日 19:37:56 petere Exp $
*
*********************************************************************
*/
@@ -1315,6 +1315,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? */
@@ -1539,8 +1541,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();
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /