@matheusbsbs / matheus-bagliano / commits / 6c912f5b04
Fork 0

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 <junkio@cox.net>

Junio C Hamano committed Feb 21, 2007 at 00:58 UTC 6c912f5b04e3216a5487e03235a8454b754a464e
1 file changed +8 -2
builtin-apply.c
+8 -2
@@ -2516,9 +2516,15 @@ static void prefix_patches(struct patch *p)
2516 if (!prefix)
2517 return;
2518 for ( ; p; p = p->next) {
2519 - if (p->new_name != p->old_name)
2519 + if (p->new_name == p->old_name) {
2520 + char *prefixed = p->new_name;
2521 + prefix_one(&prefixed);
2522 + p->new_name = p->old_name = prefixed;
2523 + }
2524 + else {
2525 prefix_one(&p->new_name);
2521 - prefix_one(&p->old_name);
2526 + prefix_one(&p->old_name);
2527 + }
2528 }
2529 }
2530