From 33c18dda237c1098201913943ca9dc0ca2ad639c Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Thu, 26 Dec 2024 21:49:24 +0000 Subject: [PATCH] plug a memory leak in gotwebd's got_open_blob_for_output() --- gotwebd/got_operations.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gotwebd/got_operations.c b/gotwebd/got_operations.c index a5a84926..f228108e 100644 --- a/gotwebd/got_operations.c +++ b/gotwebd/got_operations.c @@ -788,6 +788,7 @@ got_open_blob_for_output(struct got_blob_object **blob, int *fd, struct got_repository *repo = c->t->repo; struct got_commit_object *commit = NULL; struct got_object_id *commit_id = NULL; + struct got_object_id *blob_id = NULL; struct got_reflist_head refs; char *path = NULL, *in_repo_path = NULL; int obj_type; @@ -825,16 +826,16 @@ got_open_blob_for_output(struct got_blob_object **blob, int *fd, if (error) goto done; - error = got_object_id_by_path(&commit_id, repo, commit, in_repo_path); + error = got_object_id_by_path(&blob_id, repo, commit, in_repo_path); if (error) goto done; - if (commit_id == NULL) { + if (blob_id == NULL) { error = got_error(GOT_ERR_NO_OBJ); goto done; } - error = got_object_get_type(&obj_type, repo, commit_id); + error = got_object_get_type(&obj_type, repo, blob_id); if (error) goto done; @@ -847,7 +848,7 @@ got_open_blob_for_output(struct got_blob_object **blob, int *fd, if (error) goto done; - error = got_object_open_as_blob(blob, repo, commit_id, BUF, *fd); + error = got_object_open_as_blob(blob, repo, blob_id, BUF, *fd); if (error) goto done; @@ -871,6 +872,7 @@ got_open_blob_for_output(struct got_blob_object **blob, int *fd, got_ref_list_free(&refs); free(in_repo_path); free(commit_id); + free(blob_id); free(path); return error; } -- 2.11.4.GIT