Commit ca008b32c0b3792a048ac9f57dd80f37e90c9200

Stefan Sperling 2018-07-22T15:38:50

fix leak in got_object_open_by_path()

diff --git a/lib/object.c b/lib/object.c
index 73fbb64..eb8d9b4 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1541,9 +1541,7 @@ got_object_open_by_path(struct got_object **obj, struct got_repository *repo,
 	/* Handle opening of root of commit's tree. */
 	if (path[1] == '\0') {
 		err = got_object_open(obj, repo, commit->tree_id);
-		if (err)
-			goto done;
-		return NULL;
+		goto done;
 	}
 
 	err = got_object_open_as_tree(&tree, repo, commit->tree_id);
@@ -1599,11 +1597,9 @@ got_object_open_by_path(struct got_object **obj, struct got_repository *repo,
 		}
 	}
 
-	if (te) {
+	if (te)
 		err = got_object_open(obj, repo, te->id);
-		if (err)
-			goto done;
-	} else
+	else
 		err = got_error(GOT_ERR_NO_OBJ);
 done:
 	free(s0);