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

Skip to content
8000

Commit 247c3b2

Browse files
[3.13] gh-129346: Handle allocation errors for SQLite aggregate context (GH-129347) (#129372)
(cherry picked from commit 379ab85) Co-authored-by: Erlend E. Aasland <erlend@python.org>
1 parent d7d4edf commit 247c3b2

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