Set output to NULL if got_object_parse_tree() fails.
diff --git a/lib/object_parse.c b/lib/object_parse.c
index fea89ac..0c8445c 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -511,6 +511,7 @@ got_object_parse_tree(struct got_tree_object **tree, uint8_t *buf, size_t len)
if (remain != 0) {
got_object_tree_close(*tree);
+ *tree = NULL;
return got_error(GOT_ERR_BAD_OBJ_DATA);
}