Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r62998:1d4ae971e56f
Date: 2013-04-04 08:24 +0200
http://bitbucket.org/pypy/pypy/changeset/1d4ae971e56f/
Log: We need to keep alive the sql statement for a bit longer, since
next_char will point to some memory that we have to own at the point
of reading it.
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -1067,7 +1067,8 @@
sql = sql.encode('utf-8')
statement_star = _ffi.new('sqlite3_stmt **')
next_char = _ffi.new('char **')
- ret = _lib.sqlite3_prepare_v2(self.__con._db, sql, -1,
+ llsql = _ffi.new("char[]", sql)
+ ret = _lib.sqlite3_prepare_v2(self.__con._db, llsql, -1,
statement_star, next_char)
self._statement = statement_star[0]
@@ -1080,8 +1081,8 @@
if ret != _lib.SQLITE_OK:
raise self.__con._get_exception(ret)
- sql = _ffi.string(next_char[0]).decode('utf-8')
- if _check_remaining_sql(sql):
+ remaining_sql = _ffi.string(next_char[0]).decode('utf-8')
+ if _check_remaining_sql(remaining_sql):
raise Warning("You can only execute one statement at a time.")
def __del__(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit