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

Commitfb60118

Browse files
committed
Avoid possible longjmp-induced logic error in PLy_trigger_build_args.
The "pltargs" variable wasn't marked volatile, which makes it unsafeto change its value within the PG_TRY block. It looks like the worstoutcome would be to fail to release a refcount on Py_None during an(improbable) error exit, which would likely go unnoticed in the field.Still, it's a bug. A one-liner fix could be to mark pltargs volatile,but on the whole it seems cleaner to arrange things so that we don'tchange its value within PG_TRY.Per report from Xing Guo. This has been there for quite awhile,so back-patch to all supported branches.Discussion:https://postgr.es/m/CACpMh+DLrk=fDv07MNpBT4J413fDAm+gmMXgi8cjPONE+jvzuw@mail.gmail.com
1 parentde3c5b1 commitfb60118

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎src/pl/plpython/plpy_exec.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
693693
*pltrelid,
694694
*plttablename,
695695
*plttableschema,
696-
*pltargs=NULL,
696+
*pltargs,
697697
*pytnew,
698698
*pytold,
699699
*pltdata;
@@ -717,6 +717,11 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
717717
returnNULL;
718718
}
719719
}
720+
else
721+
{
722+
Py_INCREF(Py_None);
723+
pltargs=Py_None;
724+
}
720725

721726
PG_TRY();
722727
{
@@ -860,7 +865,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
860865
PyObject*pltarg;
861866

862867
/* pltargs should have been allocated before the PG_TRY block. */
863-
Assert(pltargs);
868+
Assert(pltargs&&pltargs!=Py_None);
864869

865870
for (i=0;i<tdata->tg_trigger->tgnargs;i++)
866871
{
@@ -874,8 +879,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
874879
}
875880
else
876881
{
877-
Py_INCREF(Py_None);
878-
pltargs=Py_None;
882+
Assert(pltargs==Py_None);
879883
}
880884
PyDict_SetItemString(pltdata,"args",pltargs);
881885
Py_DECREF(pltargs);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp