Author: Armin Rigo <[email protected]>
Branch: release-1.6.x
Changeset: r46487:140dbb95dac4
Date: 2011-08-13 20:14 +0000
http://bitbucket.org/pypy/pypy/changeset/140dbb95dac4/
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))
@@ -902,6 +903,7 @@
self.con._remember_statement(self)
if _check_remaining_sql(next_char.value):
raise Warning, "One and only one statement required"
+ # sql_char should remain alive until here
self._build_row_cast_map()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit