Commit dad8bed0 authored by Alexander Korotkov's avatar Alexander Korotkov

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
parent 969274d8
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment