diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-02-19 11:20:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 11:20:32 (GMT) |
commit | 979b23cbe44071b056ff524c0aa20e5d9794b5b0 (patch) | |
tree | 8535885fd31257d7e8269d3e5c7777a96e899c5c /Modules | |
parent | e92d67dfbb4790df37aa6a0961fb6dc7e8d2fbbf (diff) | |
download | cpython-979b23cbe44071b056ff524c0aa20e5d9794b5b0.zip cpython-979b23cbe44071b056ff524c0aa20e5d9794b5b0.tar.gz cpython-979b23cbe44071b056ff524c0aa20e5d9794b5b0.tar.bz2 |
bpo-43258: Don't allocate sqlite3 aggregate context for empty queries (GH-24569)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sqlite/connection.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 63fcb00..39b55fc 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -708,8 +708,12 @@ void _pysqlite_final_callback(sqlite3_context* context) threadstate = PyGILState_Ensure(); - aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*)); - if (!*aggregate_instance) { + aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, 0); + if (aggregate_instance == NULL) { + /* No rows matched the query; the step handler was never called. */ + goto error; + } + else if (!*aggregate_instance) { /* this branch is executed if there was an exception in the aggregate's * __init__ */ |