summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-09-21 22:05:17 (GMT)
committerGitHub <noreply@github.com>2020-09-21 22:05:17 (GMT)
commit4ee30c42441c3e5066d5080a22da53675aeae716 (patch)
tree66b8af957ffe0cdffdcf2097b188918318e02d86 /Modules/_sqlite
parent724df8325d5fffc953280363c28ed84d5a7f3008 (diff)
downloadcpython-4ee30c42441c3e5066d5080a22da53675aeae716.zip
cpython-4ee30c42441c3e5066d5080a22da53675aeae716.tar.gz
cpython-4ee30c42441c3e5066d5080a22da53675aeae716.tar.bz2
bpo-41815: SQLite: segfault if backup called on closed database (GH-22322)
GH- [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) ``` (cherry picked from commit bfee9fad84531a471fd7864e88947320669f68e2) Co-authored-by: Peter McCormick <peter@pdmccormick.com>
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/connection.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 958be7d..b800373 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;
}