https://github.com/python/cpython/commit/23faf5f2dca009f7cc18840246de405dbb7fce9f
commit: 23faf5f2dca009f7cc18840246de405dbb7fce9f
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: erlend-aasland <[email protected]>
date: 2025-01-27T17:33:18Z
summary:

[3.12] gh-129346: Handle allocation errors for SQLite aggregate context 
(GH-129347) (#129373)

(cherry picked from commit 379ab856f59423c570333403a7d5d72f3ea82d52)

Co-authored-by: Erlend E. Aasland <[email protected]>

files:
A Misc/NEWS.d/next/Library/2025-01-27-14-05-19.gh-issue-129346.gZRd3g.rst
M Modules/_sqlite/connection.c

diff --git 
a/Misc/NEWS.d/next/Library/2025-01-27-14-05-19.gh-issue-129346.gZRd3g.rst 
b/Misc/NEWS.d/next/Library/2025-01-27-14-05-19.gh-issue-129346.gZRd3g.rst
new file mode 100644
index 00000000000000..b5377277f6c51c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-01-27-14-05-19.gh-issue-129346.gZRd3g.rst
@@ -0,0 +1,2 @@
+In :mod:`sqlite3`, handle out-of-memory when creating user-defined SQL
+functions.
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 12e5c135aafa50..1450037ca95c83 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -927,6 +927,11 @@ step_callback(sqlite3_context *context, int argc, 
sqlite3_value **params)
     assert(ctx != NULL);
 
     aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, 
sizeof(PyObject*));
+    if (aggregate_instance == NULL) {
+        (void)PyErr_NoMemory();
+        set_sqlite_error(context, "unable to allocate SQLite aggregate 
context");
+        goto error;
+    }
     if (*aggregate_instance == NULL) {
         *aggregate_instance = PyObject_CallNoArgs(ctx->callable);
         if (!*aggregate_instance) {

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to