diff options
author | Gerhard Häring <gh@ghaering.de> | 2008-10-08 08:45:16 +0000 |
---|---|---|
committer | Gerhard Häring <gh@ghaering.de> | 2008-10-08 08:45:16 +0000 |
commit | f80527679b64f9c14c555db6843fac659b1e3aeb (patch) | |
tree | c7c81ea6bbe6781bda91e0c55f7c230779407bd4 /Modules/_sqlite/connection.c | |
parent | bab0f2ff662fa5e94115d2e902d3a694d61ad7f9 (diff) | |
download | cpython-git-f80527679b64f9c14c555db6843fac659b1e3aeb.tar.gz |
Issue #4046: Backport of issue #3312's patch: fixes two crashes in the sqlite3
module.
Diffstat (limited to 'Modules/_sqlite/connection.c')
-rw-r--r-- | Modules/_sqlite/connection.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 703af15fa9..d491688252 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -822,6 +822,7 @@ static int connection_set_isolation_level(Connection* self, PyObject* isolation_ { PyObject* res; PyObject* begin_statement; + char* begin_statement_str; Py_XDECREF(self->isolation_level); @@ -854,12 +855,18 @@ static int connection_set_isolation_level(Connection* self, PyObject* isolation_ 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) { + Py_DECREF(begin_statement); return -1; } - strcpy(self->begin_statement, PyString_AsString(begin_statement)); + strcpy(self->begin_statement, begin_statement_str); Py_DECREF(begin_statement); } |