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>
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 @@
         sleep_ms = (int)ms;
     }
 
+    if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
+        return NULL;
+    }
+
     if (!pysqlite_check_connection((pysqlite_Connection *)target)) {
         return NULL;
     }