Re: [PATCH] rerere: fix memory leak if rerere images can't be read
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Feb 23, 2010, 21:26 UTC
- Message-ID
- <alpine.DEB.1.00.1002232225480.3980@intel-tinevez-2-302>
- In-Reply-To
- <1266955913-4943-1-git-send-email-bert.wesarg@googlemail.com>
Hi,
On Tue, 23 Feb 2010, Bert Wesarg wrote:
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> > --- > rerere.c | 6 ++++-- > 1 files changed, 4 insertions(+), 2 deletions(-)
Looks good to me, except...
Show 16 quoted lines
> diff --git a/rerere.c b/rerere.c
> index d1d3e75..9ca4cb8 100644
> --- a/rerere.c
> +++ b/rerere.c
> @@ -364,16 +364,17 @@ 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)
> return 1;
>
> + ret = 1;This initialization can come earlier, at declaration time.
Show 8 quoted lines
> if (read_mmfile(&cur, rerere_path(name, "thisimage")) ||
> read_mmfile(&base, rerere_path(name, "preimage")) ||
> read_mmfile(&other, rerere_path(name, "postimage")))
> - return 1;
> + goto out;
> ret = ll_merge(&result, path, &base, &cur, "", &other, "", 0);
> if (!ret) {
> FILE *f = fopen(path, "w");Ciao, Dscho