Re: plpython: NULL pointer dereference on broken sequence objects

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-06-26T06:05:40Z
Lists: pgsql-hackers

Attachments

On Thu, Jun 25, 2026 at 10:05 PM Ayush Tiwari
<ayushtiwari.slg01@gmail.com> wrote:
> I think there's a similar problem on the mapping side that v1 doesn't
> cover. PLyMapping_ToJsonbValue and the hstore equivalent fetch items with
> PyMapping_Items() and PyList_GetItem() without checking for NULL, and a
> mapping whose items() raises still would crash the backend.

Right.  Those functions have the same issue as PySequence_GetItem().
The attached v2 patch fixes them all.

- Richard

Commits

  1. plpython: Fix NULL pointer dereferences for broken sequence and mapping objects