summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-26 09:43:00 -0700
committerJunio C Hamano <gitster@pobox.com>2011-05-26 09:43:00 -0700
commitd9ac3e41c37ea565d8227d942b4f468616c9813a (patch)
tree7ff9e5e77766fa3f0fae8cea269cb285939a19ef /diff.c
parent05318994e7fcb6a652a8329bf7ba7f8d6696ee3c (diff)
parent42536dd9b9829b4eb4e3706e141b3c8bffa3e826 (diff)
downloadgit-d9ac3e41c37ea565d8227d942b4f468616c9813a.tar.gz
Merge branch 'jm/maint-diff-words-with-sbe' into maint
* jm/maint-diff-words-with-sbe: do not read beyond end of malloc'd buffer
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index ba45a7df11..9a8012e362 100644
--- a/diff.c
+++ b/diff.c
@@ -1050,8 +1050,16 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
emit_line(ecbdata->opt, plain, reset, line, len);
fputs("~\n", ecbdata->opt->file);
} else {
- /* don't print the prefix character */
- emit_line(ecbdata->opt, plain, reset, line+1, len-1);
+ /*
+ * Skip the prefix character, if any. With
+ * diff_suppress_blank_empty, there may be
+ * none.
+ */
+ if (line[0] != '\n') {
+ line++;
+ len--;
+ }
+ emit_line(ecbdata->opt, plain, reset, line, len);
}
return;
}