diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2023-06-07 11:10:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-07 11:10:28 (GMT) |
commit | a24a780d937109a0982d807473ae410cc75b0e3b (patch) | |
tree | ebcd37b3a88d2f2c7b637eb1f2dbf0279f87c7a5 /Modules/_sqlite | |
parent | ffd26545509b706437ca38bd6db6108c1d0e2326 (diff) | |
download | cpython-a24a780d937109a0982d807473ae410cc75b0e3b.zip cpython-a24a780d937109a0982d807473ae410cc75b0e3b.tar.gz cpython-a24a780d937109a0982d807473ae410cc75b0e3b.tar.bz2 |
gh-105375: Improve error handling in sqlite3 collation callback (#105412)
Check for error after each call to PyUnicode_FromStringAndSize().
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r-- | Modules/_sqlite/connection.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 5c57a41..82d23c2 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1868,10 +1868,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; |