Skip to content

Commit e4b0858

Browse files
committed
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
1 parent e8b4a23 commit e4b0858

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/pl/plpython/plpython.c

Lines changed: 6 additions & 1 deletion
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.58.4.11 2010/04/30 19:16:19 tgl Exp $
32+
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.58.4.12 2010/08/25 19:37:30 petere Exp $
3333
*
3434
*********************************************************************
3535
*/
@@ -966,6 +966,8 @@ PLy_procedure_get(FunctionCallInfo fcinfo, Oid tgreloid)
966966
elog(FATAL, "expected a PyCObject, didn't get one");
967967

968968
proc = PyCObject_AsVoidPtr(plproc);
969+
if (!proc)
970+
PLy_elog(ERROR, "PyCObject_AsVoidPtr() failed");
969971
if (proc->me != plproc)
970972
elog(FATAL, "proc->me != plproc");
971973
/* did we find an up-to-date cache entry? */
@@ -1135,8 +1137,11 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
11351137
PLy_procedure_compile(proc, procSource);
11361138

11371139
pfree(procSource);
1140+
procSource = NULL;
11381141

11391142
proc->me = PyCObject_FromVoidPtr(proc, NULL);
1143+
if (!proc->me)
1144+
PLy_elog(ERROR, "PyCObject_FromVoidPtr() failed");
11401145
PyDict_SetItemString(PLy_procedure_cache, key, proc->me);
11411146
}
11421147
PG_CATCH();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy