summaryrefslogtreecommitdiff
path: root/contrib/jsonb_plpython
diff options
context:
space:
mode:
authorAlexander Korotkov2018-06-15 12:01:46 +0000
committerAlexander Korotkov2018-06-15 12:01:46 +0000
commitdad8bed04ab98ada84ecd58ace6f59839aa161c4 (patch)
tree6139001367230f79e313e3ba43bbc07f38207bf8 /contrib/jsonb_plpython
parent969274d813018b08389956e493f691671f0d84f1 (diff)
Fix memory leak in PLySequence_ToJsonbValue()
PyObject returned from PySequence_GetItem() is not released. Similar code in PLyMapping_ToJsonbValue() is correct, because according to Python documentation PyList_GetItem() and PyTuple_GetItem() return a borrowed reference while PySequence_GetItem() returns new reference. contrib/jsonb_plpython is new in PostgreSQL 11, no backpatch is needed. Author: Nikita Glukhov Discussion: https://postgr.es/m/6001af16-b242-2527-bc7e-84b8a959163b%40postgrespro.ru
Diffstat (limited to 'contrib/jsonb_plpython')
-rw-r--r--contrib/jsonb_plpython/jsonb_plpython.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/contrib/jsonb_plpython/jsonb_plpython.c b/contrib/jsonb_plpython/jsonb_plpython.c
index f752d6c3cd8..d6d6eeb9c15 100644
--- a/contrib/jsonb_plpython/jsonb_plpython.c
+++ b/contrib/jsonb_plpython/jsonb_plpython.c
@@ -308,6 +308,8 @@ PLySequence_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state)
PyObject *value = PySequence_GetItem(obj, i);
(void) PLyObject_ToJsonbValue(value, jsonb_state, true);
+
+ Py_XDECREF(value);
}
return pushJsonbValue(jsonb_state, WJB_END_ARRAY, NULL);