Skip to content

Commit dad8bed

Browse files
committed
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
1 parent 969274d commit dad8bed

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

contrib/jsonb_plpython/jsonb_plpython.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ PLySequence_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state)
308308
PyObject *value = PySequence_GetItem(obj, i);
309309

310310
(void) PLyObject_ToJsonbValue(value, jsonb_state, true);
311+
312+
Py_XDECREF(value);
311313
}
312314

313315
return pushJsonbValue(jsonb_state, WJB_END_ARRAY, NULL);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy