This PR intends to plug some leaks. It specifically implements adherence to the requirement in BDB to close a handle which failed to open (https://docs.oracle.com/cd/E17276_01/html/api_reference/C/dbopen.html):
The
DB->open()method returns a non-zero error value on failure and 0 on success. IfDB->open()fails, theDB->close()method must be called to discard the DB handle.