summaryrefslogtreecommitdiff
path: root/attr.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2007-04-22 14:11:54 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-04-22 17:44:56 (GMT)
commit4629795816bf3f58a02872ec389a92de7efd38c4 (patch)
tree0226fd64e9e6057bf3acef8b621bb6e36ac5f6bd /attr.c
parent67e22ed58f776372de5ed0a5e6fb329bc24b52b2 (diff)
downloadgit-4629795816bf3f58a02872ec389a92de7efd38c4.zip
git-4629795816bf3f58a02872ec389a92de7efd38c4.tar.gz
git-4629795816bf3f58a02872ec389a92de7efd38c4.tar.bz2
Fix crash in t0020 (crlf conversion)
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>
Diffstat (limited to 'attr.c')
-rw-r--r--attr.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/attr.c b/attr.c
index 285e689..a071254 100644
--- a/attr.c
+++ b/attr.c
@@ -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;
@@ -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);