builtin/commit-graph.c: UNLEAK variables
commit0bfb48e67230393632b9b07d8ffceae94398e5b8
authorMartin Ågren <martin.agren@gmail.com>
Wed, 3 Oct 2018 17:12:17 +0000 (3 10:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 Oct 2018 23:25:05 +0000 (7 08:25 +0900)
treea259cf5fb457a54b0c1ca38e3ae748c14e3588af
parentf4dbdfc4d514d4ea558703f5a234652dc68d83b2
builtin/commit-graph.c: UNLEAK variables

`graph_verify()`, `graph_read()` and `graph_write()` do the hard work of
`cmd_commit_graph()`. As soon as these return, so does
`cmd_commit_graph()`.

`strbuf_getline()` may allocate memory in the strbuf, yet return EOF.
We need to release the strbuf or UNLEAK it. Go for the latter since we
are close to returning from `graph_write()`.

`graph_write()` also fails to free the strings in the string list. They
have been added to the list with `strdup_strings` set to 0. We could
flip `strdup_strings` before clearing the list, which is our usual hack
in situations like this. But since we are about to exit, let's just
UNLEAK the whole string list instead.

UNLEAK `graph` in `graph_verify`. While at it, and for consistency,
UNLEAK in `graph_read()` as well, and remove an unnecessary UNLEAK just
before dying.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit-graph.c