[pypy-commit] pypy default: Fix a bug in _sqlite3.py: memory is freed too early

arigo noreply at buildbot.pypy.org
Sat Aug 13 22:15:23 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r46486:e75a624ff472
Date: 2011-08-13 20:14 +0000
http://bitbucket.org/pypy/pypy/changeset/e75a624ff472/

Log:	Fix a bug in _sqlite3.py: memory is freed too early

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -891,7 +891,8 @@
 
         self.statement = c_void_p()
         next_char = c_char_p()
-        ret = sqlite.sqlite3_prepare_v2(self.con.db, sql, -1, byref(self.statement), byref(next_char))
+        sql_char = c_char_p(sql)
+        ret = sqlite.sqlite3_prepare_v2(self.con.db, sql_char, -1, byref(self.statement), byref(next_char))
         if ret == SQLITE_OK and self.statement.value is None:
             # an empty statement, we work around that, as it's the least trouble
             ret = sqlite.sqlite3_prepare_v2(self.con.db, "select 42", -1, byref(self.statement), byref(next_char))
@@ -903,6 +904,7 @@
         if _check_remaining_sql(next_char.value):
             raise Warning, "One and only one statement required: %r" % (
                 next_char.value,)
+        # sql_char should remain alive until here
 
         self._build_row_cast_map()
 


More information about the pypy-commit mailing list