]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129346: Handle allocation errors for SQLite aggregate context (#129347)
authorErlend E. Aasland <erlend@python.org>
Mon, 27 Jan 2025 17:16:19 +0000 (18:16 +0100)
committerGitHub <noreply@github.com>
Mon, 27 Jan 2025 17:16:19 +0000 (18:16 +0100)
Misc/NEWS.d/next/Library/2025-01-27-14-05-19.gh-issue-129346.gZRd3g.rst [new file with mode: 0644]
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 (file)
index 0000000..b537727
--- /dev/null
@@ -0,0 +1,2 @@
+In :mod:`sqlite3`, handle out-of-memory when creating user-defined SQL
+functions.
index fc03e4a085c179d1678f8e1878fed653f275e39b..62598ecc86412005df4ac845dd39f95601676c04 100644 (file)
@@ -958,6 +958,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) {