8000 [3.12] gh-129346: Handle allocation errors for SQLite aggregate conte… · python/cpython@23faf5f · GitHub
[go: up one dir, main page]

Skip to content

Commit 23faf5f

Browse files
[3.12] gh-129346: Handle allocation errors for SQLite aggregate context (GH-129347) (#129373)
(cherry picked from commit 379ab85) Co-authored-by: Erlend E. Aasland <erlend@python.org>
1 parent 6073f04 commit 23faf5f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In :mod:`sqlite3`, handle out-of-memory when creating user-defined SQL
2+
functions.

Modules/_sqlite/connection.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,11 @@ step_callback(sqlite3_context *context, int argc, sqlite3_value **params)
927927
assert(ctx != NULL);
928928

929929
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
930+
if (aggregate_instance == NULL) {
931+
(void)PyErr_NoMemory();
932+
set_sqlite_error(context, "unable to allocate SQLite aggregate context");
933+
goto error;
934+
}
930935
if (*aggregate_instance == NULL) {
931936
*aggregate_instance = PyObject_CallNoArgs(ctx->callable);
932937
if (!*aggregate_instance) {

0 commit comments

Comments
 (0)
0