Git fork

revision: fix memory leak in prepare_show_merge()

In revision.c:prepare_show_merge(), we allocated an array in prune
but forget to free it. Since parse_pathspec is not responsible to
free prune, we should add `free(prune)` in the end of prepare_show_merge().

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Lidong Yan and committed by
Junio C Hamano
a3d278bb d50a5e89

+25
+1
revision.c
··· 2068 2068 parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL, 2069 2069 PATHSPEC_PREFER_FULL | PATHSPEC_LITERAL_PATH, "", prune); 2070 2070 revs->limited = 1; 2071 + free(prune); 2071 2072 } 2072 2073 2073 2074 static int dotdot_missing(const char *arg, char *dotdot,
+24
t/t7007-show.sh
··· 167 167 test_must_fail git show --graph HEAD 168 168 ' 169 169 170 + test_expect_success 'show unmerged index' ' 171 + git reset --hard && 172 + 173 + git switch -C base && 174 + echo "base" >conflicting && 175 + git add conflicting && 176 + git commit -m "base" && 177 + 178 + git branch hello && 179 + git branch goodbye && 180 + 181 + git switch hello && 182 + echo "hello" >conflicting && 183 + git commit -am "hello" && 184 + 185 + git switch goodbye && 186 + echo "goodbye" >conflicting && 187 + git commit -am "goodbye" && 188 + 189 + git switch hello && 190 + test_must_fail git merge goodbye && 191 + git show --merge HEAD 192 + ' 193 + 170 194 test_done