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

Commit30fe8a7

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 parent25675c4 commit30fe8a7

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
@@ -702,7 +702,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
702702
*pltrelid,
703703
*plttablename,
704704
*plttableschema,
705-
*pltargs=NULL,
705+
*pltargs,
706706
*pytnew,
707707
*pytold,
708708
*pltdata;
@@ -726,6 +726,11 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
726726
returnNULL;
727727
}
728728
}
729+
else
730+
{
731+
Py_INCREF(Py_None);
732+
pltargs=Py_None;
733+
}
729734

730735
PG_TRY();
731736
{
@@ -869,7 +874,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
869874
PyObject*pltarg;
870875

871876
/* pltargs should have been allocated before the PG_TRY block. */
872-
Assert(pltargs);
877+
Assert(pltargs&&pltargs!=Py_None);
873878

874879
for (i=0;i<tdata->tg_trigger->tgnargs;i++)
875880
{
@@ -883,8 +888,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
883888
}
884889
else
885890
{
886-
Py_INCREF(Py_None);
887-
pltargs=Py_None;
891+
Assert(pltargs==Py_None);
888892
}
889893
PyDict_SetItemString(pltdata,"args",pltargs);
890894
Py_DECREF(pltargs);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp