d93b97f Set to nullptr after delete (practicalswift)
Tree-SHA512: 7201cef4541557ffe31f52ce7527c4b08a2ff5aa1eae5268bdfee5b4843881f8fd115257bef6d1b4dfb71166951950a912ce87aef160ca89c2ca2ae264cfab1b
Backport of Core PR 10027
https://github.com/bitcoin/bitcoin/pull/10027/files
Changes in dbwrapper_tests.cpp have already been supersceded by an out-of-order backport.