8000 gh-129346: Handle allocation errors for SQLite aggregate context (#12… · python/cpython@379ab85 · GitHub
[go: up one dir, main page]

Skip to content

Commit 379ab85

Browse files
gh-129346: Handle allocation errors for SQLite aggregate context (#129347)
1 parent a6a8c6f commit 379ab85

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
@@ -958,6 +958,11 @@ step_callback(sqlite3_context *context, int argc, sqlite3_value **params)
958958
assert(ctx != NULL);
959959

960960
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
961+
if (aggregate_instance == NULL) {
962+
(void)PyErr_NoMemory();
963+
set_sqlite_error(context, "unable to allocate SQLite aggregate context");
964+
goto error;
965+
}
961966
if (*aggregate_instance == NULL) {
962967
*aggregate_instance = PyObject_CallNoArgs(ctx->callable);
963968
if (!*aggregate_instance) {

0 commit comments

Comments
 (0)
0