提交 689b8c29 编写于 作者: B Bert Wesarg 提交者: Junio C Hamano

rerere: fix memory leak if rerere images can't be read

Signed-off-by: NBert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 16758621
...@@ -364,7 +364,7 @@ static int find_conflict(struct string_list *conflict) ...@@ -364,7 +364,7 @@ static int find_conflict(struct string_list *conflict)
static int merge(const char *name, const char *path) static int merge(const char *name, const char *path)
{ {
int ret; int ret;
mmfile_t cur, base, other; mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0};
mmbuffer_t result = {NULL, 0}; mmbuffer_t result = {NULL, 0};
if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0) if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
...@@ -372,8 +372,10 @@ static int merge(const char *name, const char *path) ...@@ -372,8 +372,10 @@ static int merge(const char *name, const char *path)
if (read_mmfile(&cur, rerere_path(name, "thisimage")) || if (read_mmfile(&cur, rerere_path(name, "thisimage")) ||
read_mmfile(&base, rerere_path(name, "preimage")) || read_mmfile(&base, rerere_path(name, "preimage")) ||
read_mmfile(&other, rerere_path(name, "postimage"))) read_mmfile(&other, rerere_path(name, "postimage"))) {
return 1; ret = 1;
goto out;
}
ret = ll_merge(&result, path, &base, &cur, "", &other, "", 0); ret = ll_merge(&result, path, &base, &cur, "", &other, "", 0);
if (!ret) { if (!ret) {
FILE *f = fopen(path, "w"); FILE *f = fopen(path, "w");
...@@ -387,6 +389,7 @@ static int merge(const char *name, const char *path) ...@@ -387,6 +389,7 @@ static int merge(const char *name, const char *path)
strerror(errno)); strerror(errno));
} }
out:
free(cur.ptr); free(cur.ptr);
free(base.ptr); free(base.ptr);
free(other.ptr); free(other.ptr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册