From: Martin Ågren Date: Fri, 22 Sep 2017 23:34:49 +0000 (+0200) Subject: builtin/commit: fix memory leak in `prepare_index()` X-Git-Tag: v2.15.0-rc0~29^2~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/dd1055ed594f8fef18779cce3cd921c4ac66cf9c?ds=sidebyside;hp=dd1055ed594f8fef18779cce3cd921c4ac66cf9c builtin/commit: fix memory leak in `prepare_index()` 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 Reviewed-by: Jeff King Signed-off-by: Junio C Hamano ---