[Python-checkins] cpython: Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
victor.stinner
python-checkins at python.org
Tue Nov 5 18:08:01 CET 2013
http://hg.python.org/cpython/rev/00ee08fac522
changeset: 86945:00ee08fac522
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Nov 05 14:46:13 2013 +0100
summary:
Issue #19437: Fix pysqlite_connection_call() of sqlite3, return NULL when
PyList_Append() fails
files:
Modules/_sqlite/connection.c | 34 ++++++++++-------------
1 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -1229,9 +1229,8 @@
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 @@
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 @@
(void)pysqlite_statement_reset(statement);
_pysqlite_seterror(self->db, NULL);
}
-
- 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;
- }
-
- Py_DECREF(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);
+
+ return (PyObject*)statement;
+
error:
- return (PyObject*)statement;
+ Py_DECREF(statement);
+ return NULL;
}
PyObject* pysqlite_connection_execute(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list