From efee0493380c12b17c39a76761a3c72220d44132 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 24 Feb 2012 21:44:29 +0000 Subject: [PATCH] Added error check in _mogrify for failed tuple creation --- psycopg/cursor_type.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index bb9db691..f6cf3a9f 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -217,7 +217,10 @@ _mogrify(PyObject *var, PyObject *fmt, cursorObject *curs, PyObject **new) } if (n == NULL) { - n = PyTuple_New(PyObject_Length(var)); + if (!(n = PyTuple_New(PyObject_Length(var)))) { + Py_DECREF(value); + return -1; + } } /* let's have d point just after the '%' */