Skip to content

Commit

Permalink
Fix crash in t0020 (crlf conversion)
Browse files Browse the repository at this point in the history
Reallocated wrong size.
Noticed on Ubuntu 7.04 probably because it has some malloc diagnostics in libc:
"git-read-tree --reset -u HEAD" aborted in the test. Valgrind sped up the
debugging greatly: took me 10 minutes.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Alex Riesen authored and Junio C Hamano committed Apr 22, 2007
1 parent 67e22ed commit 4629795
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ static struct attr_stack *read_attr_from_array(const char **list)
a = parse_attr_line(line, "[builtin]", ++lineno, 1);
if (!a)
continue;
res->attrs = xrealloc(res->attrs, res->num_matches + 1);
res->attrs = xrealloc(res->attrs,
sizeof(struct match_attr *) * (res->num_matches + 1));
res->attrs[res->num_matches++] = a;
}
return res;
Expand All @@ -324,7 +325,8 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
a = parse_attr_line(buf, path, ++lineno, macro_ok);
if (!a)
continue;
res->attrs = xrealloc(res->attrs, res->num_matches + 1);
res->attrs = xrealloc(res->attrs,
sizeof(struct match_attr *) * (res->num_matches + 1));
res->attrs[res->num_matches++] = a;
}
fclose(fp);
Expand Down

0 comments on commit 4629795

Please sign in to comment.