pl/python: fix ref leak on elog

From: Neil Conway <neilc(at)samurai(dot)com>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: pl/python: fix ref leak on elog
Date: 2005-12-29 16:54:29
Message-ID: 43B414C5.7060007@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Attached is a simple patch that fixes a minor problem in PL/Python: in
PLy_spi_execute_plan(), we invoke the input function for a Postgres data
type. If that function elog's (which is quite possible), PL/Python leaks
references to two temporary Python objects. The fix seems easy, albeit a
bit ugly: the reference count on one of the temporary objects can be
decremented before calling the function. A pointer that points into the
second object is passed to the input function itself, so we have to
PG_CATCH() the elog and decrement the refcount then.

Since the problem might actually occur in practice and the fix seems to
have little chance of inducing a regression, I'm thinking of applying
this to both HEAD and back branches. Barring any objections I'll do that
later today or early tomorrow.

-Neil

Attachment Content-Type Size
plpython_ref_leak-3.patch text/x-patch 3.0 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-12-29 17:15:23 Re: to_char and i18n
Previous Message Qingqing Zhou 2005-12-29 07:05:35 Re: Fix spinlock usage in UnpinBuffer()