Commit 8c4eabf2088807f8965d1fa049e59f4402a3732f

Stefan Sperling 2019-05-10T18:40:10

redo: fix tree_entry_dup error path

diff --git a/lib/object.c b/lib/object.c
index d111b34..a2abc10 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1553,17 +1553,19 @@ got_object_tree_entry_dup(struct got_tree_entry **new_te,
 	(*new_te)->name = strdup(te->name);
 	if ((*new_te)->name == NULL) {
 		err = got_error_from_errno();
-		got_object_tree_entry_close(*new_te);
-		return err;
+		goto done;
 	}
 
 	(*new_te)->id = got_object_id_dup(te->id);
 	if ((*new_te)->id == NULL) {
 		err = got_error_from_errno();
+		goto done;
+	}
+done:
+	if (err) {
 		got_object_tree_entry_close(*new_te);
-		return err;
+		*new_te = NULL;
 	}
-
-	return NULL;
+	return err;
 }