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

Commite4b0858

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 parente8b4a23 commite4b0858

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)

[8]ページ先頭

©2009-2025 Movatter.jp