Re: pgsql: PL/Python: Fix potential NULL pointer dereference - Mailing list pgsql-committers

From Peter Eisentraut
Subject Re: pgsql: PL/Python: Fix potential NULL pointer dereference
Date
Msg-id ff4fa2ea-5085-40dd-aabb-110c6255dade@2ndquadrant.com
Whole thread Raw
In response to Re: pgsql: PL/Python: Fix potential NULL pointer dereference  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pgsql: PL/Python: Fix potential NULL pointer dereference  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers
On 12/5/17 14:45, Tom Lane wrote:
> On the whole it seems like it might be better to dodge this whole business
> of changing "result" inside the TRY.  You could do that if you did
> something like
> 
>                 result->rows = PyList_New(rows);
> -               if (!result->rows)
> -               {
> -                   Py_DECREF(result);
> -                   result = NULL;
> -               }
> -               else
> +               if (result->rows)
>                 {
>                     PLy_input_setup_tuple(&ininfo, tuptable->tupdesc,
> 
> and then add after the PG_END_TRY
> 
>                 if (!result->rows)
>                 {
>                     Py_DECREF(result);
>                     result = NULL;
>                 }

Yeah, that looks much better.  Next try attached.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment

pgsql-committers by date:

Previous
From: Robert Haas
Date:
Subject: pgsql: Remove bug from OPTIMIZER_DEBUG code for partition-wise join.
Next
From: Tom Lane
Date:
Subject: Re: pgsql: PL/Python: Fix potential NULL pointer dereference