Skip to content

Commit 30fe8a7

Browse files
committed
Avoid possible longjmp-induced logic error in PLy_trigger_build_args.
The "pltargs" variable wasn't marked volatile, which makes it unsafe to change its value within the PG_TRY block. It looks like the worst outcome 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't change 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 parent 25675c4 commit 30fe8a7

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
return NULL;
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy