Skip to content

Commit 14b45f7

Browse files
Handle memory allocation errors
1 parent d3c6837 commit 14b45f7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Modules/_sqlite/connection.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +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-
assert(aggregate_instance != NULL);
961+
if (aggregate_instance == NULL) {
962+
(void)PyErr_NoMemory();
963+
set_sqlite_error(context, "unable to allocate SQLite aggregate context");
964+
goto error;
965+
}
962966
if (*aggregate_instance == NULL) {
963967
*aggregate_instance = PyObject_CallNoArgs(ctx->callable);
964968
if (!*aggregate_instance) {

0 commit comments

Comments
 (0)