public inbox for [email protected]
help / color / mirror / Atom feedFrom: Nathan Bossart <[email protected]>
To: Xing Guo <[email protected]>
Cc: [email protected]
Subject: Re: PL/Python: Fix return in the middle of PG_TRY() block.
Date: Thu, 12 Jan 2023 10:44:33 -0800
Message-ID: <20230112184433.GA2104952@nathanxps13> (raw)
In-Reply-To: <CACpMh+CMsGMRKFzFMm3bYTzQmMU5nfEEoEDU2apJcc4hid36AQ@mail.gmail.com>
References: <CACpMh+CMsGMRKFzFMm3bYTzQmMU5nfEEoEDU2apJcc4hid36AQ@mail.gmail.com>
On Thu, Jan 12, 2023 at 11:19:29PM +0800, Xing Guo wrote:
> I was running static analyser against PostgreSQL and found there're 2
> return statements in PL/Python module which is not safe. Patch is
> attached.
Is the problem that PG_exception_stack and error_context_stack aren't
properly reset?
> @@ -690,12 +690,12 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
> PyObject *volatile pltdata = NULL;
> char *stroid;
>
> + pltdata = PyDict_New();
> + if (!pltdata)
> + return NULL;
> +
> PG_TRY();
> {
> - pltdata = PyDict_New();
> - if (!pltdata)
> - return NULL;
> -
> pltname = PLyUnicode_FromString(tdata->tg_trigger->tgname);
> PyDict_SetItemString(pltdata, "name", pltname);
> Py_DECREF(pltname);
There's another "return" later on in this PG_TRY block. I wonder if it's
possible to detect this sort of thing at compile time.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: PL/Python: Fix return in the middle of PG_TRY() block.
In-Reply-To: <20230112184433.GA2104952@nathanxps13>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox