Check for error after each call to PyUnicode_FromStringAndSize().
(cherry picked from commit
a24a780d937109a0982d807473ae410cc75b0e3b)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
--- /dev/null
+Fix a bug in :mod:`sqlite3` where an exception could be overwritten in the
+:meth:`collation <sqlite3.Connection.create_collation>` callback.
}
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;