Commit f8052767 authored by Gerhard Häring's avatar Gerhard Häring

Issue #4046: Backport of issue #3312's patch: fixes two crashes in the sqlite3

module.
parent bab0f2ff
...@@ -215,6 +215,9 @@ Extension Modules ...@@ -215,6 +215,9 @@ Extension Modules
- Issue #1471: Arguments to fcntl.ioctl are no longer broken on 64-bit OpenBSD - Issue #1471: Arguments to fcntl.ioctl are no longer broken on 64-bit OpenBSD
and similar platforms due to sign extension. and similar platforms due to sign extension.
- Issue #3312: Fix two crashes in sqlite3.
Tests Tests
----- -----
......
...@@ -822,6 +822,7 @@ static int connection_set_isolation_level(Connection* self, PyObject* isolation_ ...@@ -822,6 +822,7 @@ static int connection_set_isolation_level(Connection* self, PyObject* isolation_
{ {
PyObject* res; PyObject* res;
PyObject* begin_statement; PyObject* begin_statement;
char* begin_statement_str;
Py_XDECREF(self->isolation_level); Py_XDECREF(self->isolation_level);
...@@ -854,12 +855,18 @@ static int connection_set_isolation_level(Connection* self, PyObject* isolation_ ...@@ -854,12 +855,18 @@ static int connection_set_isolation_level(Connection* self, PyObject* isolation_
return -1; return -1;
} }
self->begin_statement = PyMem_Malloc(PyString_Size(begin_statement) + 2); begin_statement_str = PyString_AsString(begin_statement);
if (!begin_statement_str) {
Py_DECREF(begin_statement);
return -1;
}
self->begin_statement = PyMem_Malloc(strlen(begin_statement_str) + 2);
if (!self->begin_statement) { if (!self->begin_statement) {
Py_DECREF(begin_statement);
return -1; return -1;
} }
strcpy(self->begin_statement, PyString_AsString(begin_statement)); strcpy(self->begin_statement, begin_statement_str);
Py_DECREF(begin_statement); Py_DECREF(begin_statement);
} }
......
...@@ -128,12 +128,15 @@ static PyObject* module_register_adapter(PyObject* self, PyObject* args, PyObjec ...@@ -128,12 +128,15 @@ static PyObject* module_register_adapter(PyObject* self, PyObject* args, PyObjec
{ {
PyTypeObject* type; PyTypeObject* type;
PyObject* caster; PyObject* caster;
int rc;
if (!PyArg_ParseTuple(args, "OO", &type, &caster)) { if (!PyArg_ParseTuple(args, "OO", &type, &caster)) {
return NULL; return NULL;
} }
microprotocols_add(type, (PyObject*)&SQLitePrepareProtocolType, caster); rc = microprotocols_add(type, (PyObject*)&SQLitePrepareProtocolType, caster);
if (rc == -1)
return NULL;
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment