diff options
| author | Bert Wesarg <bert.wesarg@googlemail.com> | 2010-02-23 21:11:53 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2010-02-23 14:24:43 -0800 |
| commit | 689b8c290db9d5880699dd3538134daffc1c55d0 (patch) | |
| tree | a06aff089acd1adda1aeb34d1be2fd0f7cd1dcff /rerere.c | |
| parent | Documentation: mention conflict marker size argument (%L) for merge driver (diff) | |
| download | git-689b8c290db9d5880699dd3538134daffc1c55d0.tar.gz git-689b8c290db9d5880699dd3538134daffc1c55d0.zip | |
rerere: fix memory leak if rerere images can't be read
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
| -rw-r--r-- | rerere.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -364,7 +364,7 @@ static int find_conflict(struct string_list *conflict) static int merge(const char *name, const char *path) { int ret; - mmfile_t cur, base, other; + mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0}; mmbuffer_t result = {NULL, 0}; if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0) @@ -372,8 +372,10 @@ static int merge(const char *name, const char *path) if (read_mmfile(&cur, rerere_path(name, "thisimage")) || read_mmfile(&base, rerere_path(name, "preimage")) || - read_mmfile(&other, rerere_path(name, "postimage"))) - return 1; + read_mmfile(&other, rerere_path(name, "postimage"))) { + ret = 1; + goto out; + } ret = ll_merge(&result, path, &base, &cur, "", &other, "", 0); if (!ret) { FILE *f = fopen(path, "w"); @@ -387,6 +389,7 @@ static int merge(const char *name, const char *path) strerror(errno)); } +out: free(cur.ptr); free(base.ptr); free(other.ptr); |
