summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-05 13:46:13 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-05 13:46:13 (GMT)
commitb3e1ef1ce0e4c81c43b3c49c0db9a3047d90280b (patch)
treef4dff8927a2641a1b429aedab6aa78e32354fcaa /Modules/_sqlite
parentdd4b299df1589dea63f4067b5617869d7baa7e23 (diff)
downloadcpython-b3e1ef1ce0e4c81c43b3c49c0db9a3047d90280b.zip
cpython-b3e1ef1ce0e4c81c43b3c49c0db9a3047d90280b.tar.gz
cpython-b3e1ef1ce0e4c81c43b3c49c0db9a3047d90280b.tar.bz2
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
PyList_Append() fails
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/connection.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 2b12f8b..0411d23 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -1229,9 +1229,8 @@ PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, Py
return NULL;
}
- if (!PyArg_ParseTuple(args, "O", &sql)) {
+ if (!PyArg_ParseTuple(args, "O", &sql))
return NULL;
- }
_pysqlite_drop_unused_statement_references(self);
@@ -1247,7 +1246,6 @@ PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, Py
statement->in_weakreflist = NULL;
rc = pysqlite_statement_create(statement, self, sql);
-
if (rc != SQLITE_OK) {
if (rc == PYSQLITE_TOO_MUCH_SQL) {
PyErr_SetString(pysqlite_Warning, "You can only execute one statement at a time.");
@@ -1257,25 +1255,23 @@ PyObject* pysqlite_connection_call(pysqlite_Connection* self, PyObject* args, Py
(void)pysqlite_statement_reset(statement);
_pysqlite_seterror(self->db, NULL);
}
+ goto error;
+ }
- Py_CLEAR(statement);
- } else {
- weakref = PyWeakref_NewRef((PyObject*)statement, NULL);
- if (!weakref) {
- Py_CLEAR(statement);
- goto error;
- }
-
- if (PyList_Append(self->statements, weakref) != 0) {
- Py_CLEAR(weakref);
- goto error;
- }
-
+ weakref = PyWeakref_NewRef((PyObject*)statement, NULL);
+ if (weakref == NULL)
+ goto error;
+ if (PyList_Append(self->statements, weakref) != 0) {
Py_DECREF(weakref);
+ goto error;
}
+ Py_DECREF(weakref);
-error:
return (PyObject*)statement;
+
+error:
+ Py_DECREF(statement);
+ return NULL;
}
PyObject* pysqlite_connection_execute(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)