summaryrefslogtreecommitdiffstats
path: root/convert.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-08-01 12:41:06 +0200
committerJunio C Hamano <gitster@pobox.com>2024-08-01 17:47:37 +0200
commit1f0899978109d732abe5b4825b5cfa40ef1d5885 (patch)
tree097f65a52a9e9e6878970618b6199c626eda3ee4 /convert.c
parentobject-name: fix leaking commit list items (diff)
downloadgit-1f0899978109d732abe5b4825b5cfa40ef1d5885.tar.xz
git-1f0899978109d732abe5b4825b5cfa40ef1d5885.zip
entry: fix leaking pathnames during delayed checkout
When filtering files during delayed checkout, we pass a string list to `async_query_available_blobs()`. This list is initialized with NODUP, and thus inserted strings will not be owned by the list. In the latter function we then try to hand over ownership by passing an `xstrup()`'d value to `string_list_insert()`. But this is not how this works: a NODUP list does not take ownership of allocated strings and will never free them for the caller. Fix this issue by initializing the list as `DUP` instead and dropping the explicit call to `xstrdup()`. This is okay to do given that this is the single callsite of `async_query_available_blobs()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/convert.c b/convert.c
index d8737fe0f2..61a540e212 100644
--- a/convert.c
+++ b/convert.c
@@ -960,7 +960,7 @@ int async_query_available_blobs(const char *cmd, struct string_list *available_p
while ((line = packet_read_line(process->out, NULL))) {
const char *path;
if (skip_prefix(line, "pathname=", &path))
- string_list_insert(available_paths, xstrdup(path));
+ string_list_insert(available_paths, path);
else
; /* ignore unknown keys */
}