From f9b798aca9822b9b09e0b000e6410261bad3730c Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 28 Dec 2018 03:35:28 +0100 Subject: [PATCH] Avoid unlikely leaks in case of memory errors in Bytes_Format --- psycopg/bytes_format.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/psycopg/bytes_format.c b/psycopg/bytes_format.c index 767aafa5..040db402 100644 --- a/psycopg/bytes_format.c +++ b/psycopg/bytes_format.c @@ -244,10 +244,14 @@ Bytes_Format(PyObject *format, PyObject *args) if (reslen < 0) { Py_DECREF(result); Py_XDECREF(temp); + if (args_owned) + Py_DECREF(args); return PyErr_NoMemory(); } if (_Bytes_Resize(&result, reslen)) { Py_XDECREF(temp); + if (args_owned) + Py_DECREF(args); return NULL; } res = Bytes_AS_STRING(result)