Skip to content

Commit

Permalink
pythongh-129346: Handle allocation errors for SQLite aggregate context (
Browse files Browse the repository at this point in the history
pythonGH-129347)

(cherry picked from commit 379ab85)

Co-authored-by: Erlend E. Aasland <[email protected]>
  • Loading branch information
erlend-aasland authored and miss-islington committed Jan 27, 2025
1 parent d7d4edf commit 197c115
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In :mod:`sqlite3`, handle out-of-memory when creating user-defined SQL
functions.
5 changes: 5 additions & 0 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 197c115

Please sign in to comment.