Skip to content

Commit

Permalink
apply: fix memory leak in prefix_one()
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
dscho authored and Junio C Hamano committed Feb 20, 2007
1 parent 56185f4 commit eac70c4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -2502,20 +2502,23 @@ static int use_patch(struct patch *p)
return 1;
}

static char *prefix_one(char *name)
static void prefix_one(char **name)
{
if (!name)
return name;
return xstrdup(prefix_filename(prefix, prefix_length, name));
char *old_name = *name;
if (!old_name)
return;
*name = xstrdup(prefix_filename(prefix, prefix_length, *name));
free(old_name);
}

static void prefix_patches(struct patch *p)
{
if (!prefix)
return;
for ( ; p; p = p->next) {
p->new_name = prefix_one(p->new_name);
p->old_name = prefix_one(p->old_name);
if (p->new_name != p->old_name)
prefix_one(&p->new_name);
prefix_one(&p->old_name);
}
}

Expand Down

0 comments on commit eac70c4

Please sign in to comment.