Commit Diff


commit - 117e771c4a3fee5f8e2f87bcb7d3314b99ccdc28
commit + 7a132809bdab22b3b3e7fa12588930979f19acd5
blob - d026b2cd18dd125bead7b6b9764257a26fb6bd59
blob + b08d9411dd2250a534c4923a21e284a18649cf59
--- lib/object.c
+++ lib/object.c
@@ -309,7 +309,7 @@ static const struct got_error *
 object_path(char **path, struct got_object_id *id, struct got_repository *repo)
 {
 	const struct got_error *err = NULL;
-	char *hex;
+	char *hex = NULL;
 	char *path_objects = got_repo_get_path_objects(repo);
 
 	*path = NULL;
@@ -319,12 +319,13 @@ object_path(char **path, struct got_object_id *id, str
 
 	err = got_object_id_str(&hex, id);
 	if (err)
-		return err;
+		goto done;
 
 	if (asprintf(path, "%s/%.2x/%s", path_objects,
 	    id->sha1[0], hex + 2) == -1)
 		err = got_error_from_errno();
 
+done:
 	free(hex);
 	free(path_objects);
 	return err;