diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-22 11:24:50 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-22 11:24:50 (GMT) |
commit | 9b05700ed3e395a87398bfd878bd92e65f682bce (patch) | |
tree | a176a157cfad0661bf8be34dbd128a075ec57e74 /Modules | |
parent | d0ab48f1c4bb5cbe96a799f9271f36c51c3debd3 (diff) | |
download | cpython-9b05700ed3e395a87398bfd878bd92e65f682bce.zip cpython-9b05700ed3e395a87398bfd878bd92e65f682bce.tar.gz cpython-9b05700ed3e395a87398bfd878bd92e65f682bce.tar.bz2 |
Merged revisions 80349 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r80349 | victor.stinner | 2010-04-22 13:23:23 +0200 (jeu., 22 avril 2010) | 3 lines
Issue #8195: Fix a crash in sqlite Connection.create_collation() if the
collation name contains a surrogate character.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sqlite/connection.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 4b8088d..11fb4ac 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1228,7 +1228,9 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args) PyObject* uppercase_name = 0; PyObject* name; PyObject* retval; - char* chk; + Py_UNICODE* chk; + Py_ssize_t i, len; + char *uppercase_name_str; int rc; if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { @@ -1244,19 +1246,24 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args) goto finally; } - chk = _PyUnicode_AsString(uppercase_name); - while (*chk) { + len = PyUnicode_GET_SIZE(uppercase_name); + chk = PyUnicode_AS_UNICODE(uppercase_name); + for (i=0; i<len; i++, chk++) { if ((*chk >= '0' && *chk <= '9') || (*chk >= 'A' && *chk <= 'Z') || (*chk == '_')) { - chk++; + continue; } else { PyErr_SetString(pysqlite_ProgrammingError, "invalid character in collation name"); goto finally; } } + uppercase_name_str = _PyUnicode_AsString(uppercase_name); + if (!uppercase_name_str) + goto finally; + if (callable != Py_None && !PyCallable_Check(callable)) { PyErr_SetString(PyExc_TypeError, "parameter must be callable"); goto finally; @@ -1269,7 +1276,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args) } rc = sqlite3_create_collation(self->db, - _PyUnicode_AsString(uppercase_name), + uppercase_name_str, SQLITE_UTF8, (callable != Py_None) ? callable : NULL, (callable != Py_None) ? pysqlite_collation_callback : NULL); |