You should check the returned rc before over-writing it with mdb_open()'s return !