OSDN Git Service

wt-status.c: fix a memleak
authorStefan Beller <sbeller@google.com>
Tue, 31 Mar 2015 01:22:09 +0000 (18:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 31 Mar 2015 05:12:38 +0000 (22:12 -0700)
wt_shortstatus_print_tracking() calls shorten_unambiguous_ref(),
which returns a newly allocated memory the caller takes ownership
of; it is necessary to free `base` when the function is done with
it.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wt-status.c

index ec7344e..3ec4383 100644 (file)
@@ -1541,6 +1541,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
        base = shorten_unambiguous_ref(base, 0);
        color_fprintf(s->fp, header_color, "...");
        color_fprintf(s->fp, branch_color_remote, "%s", base);
+       free((char *)base);
 
        if (!upstream_is_gone && !num_ours && !num_theirs) {
                fputc(s->null_termination ? '\0' : '\n', s->fp);