abbrev_sha1_in_line: don't leak memory
authorStefan Beller <sbeller@google.com>
Fri, 1 Apr 2016 00:35:44 +0000 (17:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Apr 2016 17:32:43 +0000 (10:32 -0700)
`split` is of type `struct strbuf **`, and currently we are leaking split
itself as well as each element in split[i]. We have a dedicated free
function for `struct strbuf **`, which takes care of freeing all
related memory.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wt-status.c
index bba25960b4e3c54a7c1d8861ea895fbe01aa3110..9f4be333d451b01ea2d40d17e41f887a300afee2 100644 (file)
@@ -1063,9 +1063,7 @@ static void abbrev_sha1_in_line(struct strbuf *line)
                                strbuf_addf(line, "%s", split[i]->buf);
                }
        }
-       for (i = 0; split[i]; i++)
-               strbuf_release(split[i]);
-
+       strbuf_list_free(split);
 }
 
 static void read_rebase_todolist(const char *fname, struct string_list *lines)