From bfee9fad84531a471fd7864e88947320669f68e2 Mon Sep 17 00:00:00 2001 From: Peter McCormick Date: Sat, 19 Sep 2020 23:40:46 -0400 Subject: bpo-41815: SQLite: segfault if backup called on closed database (GH-22322) # [bpo-41815](): SQLite: fix segfault if backup called on closed database Attempting to backup a closed database will trigger segfault: ```python import sqlite3 target = sqlite3.connect(':memory:') source = sqlite3.connect(':memory:') source.close() source.backup(target) ``` --- Modules/_sqlite/connection.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Modules/_sqlite/connection.c') diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index f765ba1df2..81fc133537 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1514,6 +1514,10 @@ pysqlite_connection_backup(pysqlite_Connection *self, PyObject *args, PyObject * sleep_ms = (int)ms; } + if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) { + return NULL; + } + if (!pysqlite_check_connection((pysqlite_Connection *)target)) { return NULL; } -- cgit v1.2.1