Skip to content

Commit

Permalink
Fix filename scaling for binary files
Browse files Browse the repository at this point in the history
Set maximum filename length for binary files so that scaling won't be
triggered and result in invalid string access.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jonas Fonseca authored and Junio C Hamano committed Apr 18, 2006
1 parent 4baff50 commit 8d6e103
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,14 @@ static void show_stats(struct diffstat_t* data)
for (i = 0; i < data->nr; i++) {
struct diffstat_file *file = data->files[i];

len = strlen(file->name);
if (max_len < len)
max_len = len;

if (file->is_binary || file->is_unmerged)
continue;
if (max_change < file->added + file->deleted)
max_change = file->added + file->deleted;
len = strlen(file->name);
if (max_len < len)
max_len = len;
}

for (i = 0; i < data->nr; i++) {
Expand Down

0 comments on commit 8d6e103

Please sign in to comment.