diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-09-21 22:00:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-21 22:00:34 (GMT) |
commit | ca2d99d091a5b7768e92ee5ce7104aa6d8a3ed86 (patch) | |
tree | 8e46e217e539f10a3276424ce51e57cad18476cb /Modules/_sqlite | |
parent | 488e3eb70d24d5ce55ae0d7aed13a3721d3eb8a1 (diff) | |
download | cpython-ca2d99d091a5b7768e92ee5ce7104aa6d8a3ed86.zip cpython-ca2d99d091a5b7768e92ee5ce7104aa6d8a3ed86.tar.gz cpython-ca2d99d091a5b7768e92ee5ce7104aa6d8a3ed86.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.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index ebe073f..b6188a3 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1523,6 +1523,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; } |