forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc08c852

Neil Conway
In PLy_function_build_args(), the code loops repeatedly, constructing
one argument at a time and then inserting the argument into a Pythonlist via PyList_SetItem(). This "steals" the reference to the argument:that is, the reference to the new list member is now held by the Pythonlist itself. This works fine, except if an elog occurs. This causes thefunction's PG_CATCH() block to be invoked, which decrements thereference counts on both the current argument and the list of arguments.If the elog happens to occur during the second or subsequent iterationof the loop, the reference count on the current argument will bedecremented twice.The fix is simple: set the local pointer to the current argument to NULLimmediately after adding it to the argument list. This ensures that thePy_XDECREF() in the PG_CATCH() block doesn't double-decrement.1 parent42ff6a0 commitc08c852
1 file changed
+2
-1
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
32 |
| - | |
| 32 | + | |
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
| |||
895 | 895 |
| |
896 | 896 |
| |
897 | 897 |
| |
| 898 | + | |
898 | 899 |
| |
899 | 900 |
| |
900 | 901 |
| |
|
0 commit comments
Comments
(0)