Prevent segfaults when attempting to read/write an unopened database