]> granicus.if.org Git - postgresql/commit
In PLy_function_build_args(), the code loops repeatedly, constructing
authorNeil Conway <neilc@samurai.com>
Tue, 10 Jan 2006 00:33:48 +0000 (00:33 +0000)
committerNeil Conway <neilc@samurai.com>
Tue, 10 Jan 2006 00:33:48 +0000 (00:33 +0000)
commit95f88ddf4940ec2b1adf3e251f54914fc668c802
tree16b3c4be9c0ca8b7f8bb2ea0d5c0c1d9e16380e3
parent59327401cc3439ce19092a018f1f8cbe17318fad
In PLy_function_build_args(), the code loops repeatedly, constructing
one argument at a time and then inserting the argument into a Python
list via PyList_SetItem(). This "steals" the reference to the argument:
that is, the reference to the new list member is now held by the Python
list itself. This works fine, except if an elog occurs. This causes the
function's PG_CATCH() block to be invoked, which decrements the
reference counts on both the current argument and the list of arguments.
If the elog happens to occur during the second or subsequent iteration
of the loop, the reference count on the current argument will be
decremented twice.

The fix is simple: set the local pointer to the current argument to NULL
immediately after adding it to the argument list. This ensures that the
Py_XDECREF() in the PG_CATCH() block doesn't double-decrement.
src/pl/plpython/plpython.c