ldb: Remove use after free in error case