X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/8b4052ad6015aa9f54c9c824f28655f230d09d8d..a047e3e158d560af079bec920460711d8222317c:/keydb_db4.c diff --git a/keydb_db4.c b/keydb_db4.c index 899cd87..0d7b46b 100644 --- a/keydb_db4.c +++ b/keydb_db4.c @@ -224,17 +224,25 @@ void cleanupdb(void) { int i = 0; - dbenv->txn_checkpoint(dbenv, 0, 0, 0); - id32db->close(id32db, 0); - id32db = NULL; - worddb->close(worddb, 0); - worddb = NULL; - for (i = 0; i < numdbs; i++) { - dbconns[i]->close(dbconns[i], 0); - dbconns[i] = NULL; + if (dbenv != NULL) { + dbenv->txn_checkpoint(dbenv, 0, 0, 0); + if (id32db != NULL) { + id32db->close(id32db, 0); + id32db = NULL; + } + if (worddb != NULL) { + worddb->close(worddb, 0); + worddb = NULL; + } + for (i = 0; i < numdbs; i++) { + if (dbconns[i] != NULL) { + dbconns[i]->close(dbconns[i], 0); + dbconns[i] = NULL; + } + } + dbenv->close(dbenv, 0); + dbenv = NULL; } - dbenv->close(dbenv, 0); - dbenv = NULL; } /**