From: Junio C Hamano Date: Wed, 21 Feb 2007 08:58:18 +0000 (-0800) Subject: Fix botched "leak fix" X-Git-Tag: v1.5.1-rc1~258^3~3 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=6c912f5b04e3216a5487e03235a8454b754a464e;p=git.git Fix botched "leak fix" When (new_name == old_name), the previous one prefixed old_name alone, leaving new_name untouched, and worse yet, left it dangling pointing at an already freed memory location. Signed-off-by: Junio C Hamano --- diff --git a/builtin-apply.c b/builtin-apply.c index 2a40af3ff..1beebe5ff 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -2516,9 +2516,15 @@ static void prefix_patches(struct patch *p) if (!prefix) return; for ( ; p; p = p->next) { - if (p->new_name != p->old_name) + if (p->new_name == p->old_name) { + char *prefixed = p->new_name; + prefix_one(&prefixed); + p->new_name = p->old_name = prefixed; + } + else { prefix_one(&p->new_name); - prefix_one(&p->old_name); + prefix_one(&p->old_name); + } } }