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

Commit08bdf0a

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 parent03561a6 commit08bdf0a

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
@@ -691,7 +691,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
691691
*pltrelid,
692692
*plttablename,
693693
*plttableschema,
694-
*pltargs=NULL,
694+
*pltargs,
695695
*pytnew,
696696
*pytold,
697697
*pltdata;
@@ -715,6 +715,11 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
715715
returnNULL;
716716
}
717717
}
718+
else
719+
{
720+
Py_INCREF(Py_None);
721+
pltargs=Py_None;
722+
}
718723

719724
PG_TRY();
720725
{
@@ -858,7 +863,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
858863
PyObject*pltarg;
859864

860865
/* pltargs should have been allocated before the PG_TRY block. */
861-
Assert(pltargs);
866+
Assert(pltargs&&pltargs!=Py_None);
862867

863868
for (i=0;i<tdata->tg_trigger->tgnargs;i++)
864869
{
@@ -872,8 +877,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
872877
}
873878
else
874879
{
875-
Py_INCREF(Py_None);
876-
pltargs=Py_None;
880+
Assert(pltargs==Py_None);
877881
}
878882
PyDict_SetItemString(pltdata,"args",pltargs);
879883
Py_DECREF(pltargs);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp