Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc76a4f8

Browse files
committed
Catch null pointer returns from PyCObject_AsVoidPtr and PyCObject_FromVoidPtr
This is reproducibly possible in Python 2.7 if the user turnedPendingDeprecationWarning into an error, but it's theoretically also possiblein earlier versions in case of exceptional conditions.backpatched to 8.0
1 parent52ba9a5 commitc76a4f8

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
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plpython.c - python as a procedural language for PostgreSQL
33
*
4-
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.148 2010/07/08 19:00:11 tgl Exp $
4+
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.149 2010/08/25 19:37:56 petere Exp $
55
*
66
*********************************************************************
77
*/
@@ -1315,6 +1315,8 @@ PLy_procedure_get(FunctionCallInfo fcinfo, Oid tgreloid)
13151315
elog(FATAL,"expected a PyCObject, didn't get one");
13161316

13171317
proc=PyCObject_AsVoidPtr(plproc);
1318+
if (!proc)
1319+
PLy_elog(ERROR,"PyCObject_AsVoidPtr() failed");
13181320
if (proc->me!=plproc)
13191321
elog(FATAL,"proc->me != plproc");
13201322
/* did we find an up-to-date cache entry? */
@@ -1539,8 +1541,11 @@ PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key)
15391541
PLy_procedure_compile(proc,procSource);
15401542

15411543
pfree(procSource);
1544+
procSource=NULL;
15421545

15431546
proc->me=PyCObject_FromVoidPtr(proc,NULL);
1547+
if (!proc->me)
1548+
PLy_elog(ERROR,"PyCObject_FromVoidPtr() failed");
15441549
PyDict_SetItemString(PLy_procedure_cache,key,proc->me);
15451550
}
15461551
PG_CATCH();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp