Avoid segfault in diff --stat rename output.
authorSean <seanlkml@sympatico.ca>
Tue, 23 May 2006 00:36:34 +0000 (20:36 -0400)
committerJunio C Hamano <junkio@cox.net>
Tue, 23 May 2006 01:00:38 +0000 (18:00 -0700)
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff.c

diff --git a/diff.c b/diff.c
index 1601783..3a2a175 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -237,7 +237,7 @@ static char *pprint_rename(const char *a, const char *b)
                if (a_midlen < 0) a_midlen = 0;
                if (b_midlen < 0) b_midlen = 0;
 
-               name = xmalloc(len_a + len_b - pfx_length - sfx_length + 7);
+               name = xmalloc(pfx_length + a_midlen + b_midlen + sfx_length + 7);
                sprintf(name, "%.*s{%.*s => %.*s}%s",
                        pfx_length, a,
                        a_midlen, a + pfx_length,