aboutsummaryrefslogtreecommitdiffstats
path: root/checkout.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-27 13:46:06 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-27 11:19:58 -0700
commitcc395d6b47e4af59b3e87a64b34dffa79e8dc262 (patch)
treeb1e71b4797f89fe945f2ee87860ee24bcefa37be /checkout.c
parentstrbuf: fix leak when `appendwholeline()` fails with EOF (diff)
downloadgit-cc395d6b47e4af59b3e87a64b34dffa79e8dc262.tar.gz
git-cc395d6b47e4af59b3e87a64b34dffa79e8dc262.zip
checkout: clarify memory ownership in `unique_tracking_name()`
The function `unique_tracking_name()` returns an allocated string, but does not clearly indicate this because its return type is `const char *` instead of `char *`. This has led to various callsites where we never free its returned memory at all, which causes memory leaks. Plug those leaks and mark now-passing tests as leak free. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'checkout.c')
-rw-r--r--checkout.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/checkout.c b/checkout.c
index 4256e71a7c..cfaea4bd10 100644
--- a/checkout.c
+++ b/checkout.c
@@ -45,8 +45,8 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
return 0;
}
-const char *unique_tracking_name(const char *name, struct object_id *oid,
- int *dwim_remotes_matched)
+char *unique_tracking_name(const char *name, struct object_id *oid,
+ int *dwim_remotes_matched)
{
struct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;
const char *default_remote = NULL;