]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#1480: fix refleak in the sqlite module.
authorGeorg Brandl <georg@python.org>
Sun, 25 Nov 2007 00:45:05 +0000 (00:45 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 25 Nov 2007 00:45:05 +0000 (00:45 +0000)
It came from rev 58682. The reason is that PyString_Concat
and PyUnicode_Concat work differently -- the equivalent to
PyString_Concat is PyUnicode_Append.

Modules/_sqlite/connection.c

index d4318deec0474efa586acc02e131981bd132cb28..b6f64924922c7a6015e158be87522863540be231 100644 (file)
@@ -806,6 +806,7 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
 {
     PyObject* res;
     PyObject* begin_statement;
+    static PyObject* begin_word;
 
     Py_XDECREF(self->isolation_level);
 
@@ -832,11 +833,11 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
         Py_INCREF(isolation_level);
         self->isolation_level = isolation_level;
 
-        begin_statement = PyUnicode_FromString("BEGIN ");
-        if (!begin_statement) {
-            return -1;
+        if (!begin_word) {
+            begin_word = PyUnicode_FromString("BEGIN ");
+            if (!begin_word) return -1;
         }
-        PyUnicode_Concat(begin_statement, isolation_level);
+        begin_statement = PyUnicode_Concat(begin_word, isolation_level);
         if (!begin_statement) {
             return -1;
         }