libdb: fix memory deallocation