summaryrefslogtreecommitdiff
path: root/MySQLdb
diff options
context:
space:
mode:
authorkylev <kylev@9fc6cd9a-920d-0410-adcf-ac96716ed7e8>2009-07-24 00:18:07 +0000
committerkylev <kylev@9fc6cd9a-920d-0410-adcf-ac96716ed7e8>2009-07-24 00:18:07 +0000
commit29b884d0cc71d44c63718a5f3ad8040f20ad747b (patch)
tree5667b71ed9bd9a05aba642a9fed10159a048e909 /MySQLdb
parentfcbf7c97914e282ae031c0d341c8be7d99bcb13b (diff)
downloadmysqldb1-29b884d0cc71d44c63718a5f3ad8040f20ad747b.tar.gz
Defer adding references until after all our C calls so we can avoid having
to decrement them if we bail out early. Fixes bug 2811033.
Diffstat (limited to 'MySQLdb')
-rw-r--r--MySQLdb/_mysql.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c
index 1683c1d..ad0d4f3 100644
--- a/MySQLdb/_mysql.c
+++ b/MySQLdb/_mysql.c
@@ -514,20 +514,10 @@ _mysql_ConnectionObject_Initialize(
))
return -1;
- if (!conv)
- conv = PyDict_New();
-#if PY_VERSION_HEX > 0x02000100
- else
- Py_INCREF(conv);
-#endif
- if (!conv)
- return -1;
- self->converter = conv;
-
#define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\
if(t){d=PyString_AsString(t);Py_DECREF(t);}\
PyErr_Clear();}
-
+
if (ssl) {
#if HAVE_OPENSSL
PyObject *value = NULL;
@@ -581,6 +571,17 @@ _mysql_ConnectionObject_Initialize(
_mysql_Exception(self);
return -1;
}
+
+ /* Internal references to python-land objects */
+ if (!conv)
+ conv = PyDict_New();
+ else
+ Py_INCREF(conv);
+
+ if (!conv)
+ return -1;
+ self->converter = conv;
+
/*
PyType_GenericAlloc() automatically sets up GC allocation and
tracking for GC objects, at least in 2.2.1, so it does not need to