[Python-checkins] r66843 - in python/branches/release25-maint: Misc/NEWS Modules/_sqlite/connection.c Modules/_sqlite/module.c

gerhard.haering python-checkins at python.org
Wed Oct 8 10:45:17 CEST 2008


Author: gerhard.haering
Date: Wed Oct 8 10:45:16 2008
New Revision: 66843
Log:
Issue #4046: Backport of issue #3312's patch: fixes two crashes in the sqlite3
module.
Modified:
 python/branches/release25-maint/Misc/NEWS
 python/branches/release25-maint/Modules/_sqlite/connection.c
 python/branches/release25-maint/Modules/_sqlite/module.c
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Wed Oct 8 10:45:16 2008
@@ -215,6 +215,9 @@
 - Issue #1471: Arguments to fcntl.ioctl are no longer broken on 64-bit OpenBSD
 and similar platforms due to sign extension.
 
+- Issue #3312: Fix two crashes in sqlite3.
+
+
 Tests
 -----
 
Modified: python/branches/release25-maint/Modules/_sqlite/connection.c
==============================================================================
--- python/branches/release25-maint/Modules/_sqlite/connection.c	(original)
+++ python/branches/release25-maint/Modules/_sqlite/connection.c	Wed Oct 8 10:45:16 2008
@@ -822,6 +822,7 @@
 {
 PyObject* res;
 PyObject* begin_statement;
+ char* begin_statement_str;
 
 Py_XDECREF(self->isolation_level);
 
@@ -854,12 +855,18 @@
 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);
 }
 
Modified: python/branches/release25-maint/Modules/_sqlite/module.c
==============================================================================
--- python/branches/release25-maint/Modules/_sqlite/module.c	(original)
+++ python/branches/release25-maint/Modules/_sqlite/module.c	Wed Oct 8 10:45:16 2008
@@ -128,12 +128,15 @@
 {
 PyTypeObject* type;
 PyObject* caster;
+ int rc;
 
 if (!PyArg_ParseTuple(args, "OO", &type, &caster)) {
 return NULL;
 }
 
- microprotocols_add(type, (PyObject*)&SQLitePrepareProtocolType, caster);
+ rc = microprotocols_add(type, (PyObject*)&SQLitePrepareProtocolType, caster);
+ if (rc == -1)
+ return NULL;
 
 Py_INCREF(Py_None);
 return Py_None;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /