builtin/commit: fix memory leak in `prepare_index()`
authorMartin Ågren <martin.agren@gmail.com>
Fri, 22 Sep 2017 23:34:49 +0000 (01:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 24 Sep 2017 01:05:45 +0000 (10:05 +0900)
Release `pathspec` and the string list `partial`.

When we clear the string list, make sure we do not free the `util`
pointers. That would result in double-freeing, since we set them up as
`item->util = item` in `list_paths()`.

Initialize the string list early, so that we can always release it. That
introduces some unnecessary overhead in various code paths, but means
there is one and only one way out of the function. If we ever accumulate
more things we need to free, it should be straightforward to do so.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
No differences found