mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
[3.11] gh-105375: Improve error handling in sqlite3 collation callback (GH-105412) (#105441)
Check for error after each call to PyUnicode_FromStringAndSize().
(cherry picked from commit a24a780d93)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
18e9fd80d9
commit
571ec56b65
2 changed files with 7 additions and 3 deletions
|
|
@ -0,0 +1,2 @@
|
|||
Fix a bug in :mod:`sqlite3` where an exception could be overwritten in the
|
||||
:meth:`collation <sqlite3.Connection.create_collation>` callback.
|
||||
|
|
@ -1792,10 +1792,12 @@ collation_callback(void *context, int text1_length, const void *text1_data,
|
|||
}
|
||||
|
||||
string1 = PyUnicode_FromStringAndSize((const char*)text1_data, text1_length);
|
||||
if (string1 == NULL) {
|
||||
goto finally;
|
||||
}
|
||||
string2 = PyUnicode_FromStringAndSize((const char*)text2_data, text2_length);
|
||||
|
||||
if (!string1 || !string2) {
|
||||
goto finally; /* failed to allocate strings */
|
||||
if (string2 == NULL) {
|
||||
goto finally;
|
||||
}
|
||||
|
||||
callback_context *ctx = (callback_context *)context;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue