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>
Alex Riesen committed
Apr 22, 2007 at 16:11 UTC
4629795816bf3f58a02872ec389a92de7efd38c4
1 file changed
+4
-2
attr.c
+4
-2
@@ -300,7 +300,8 @@ static struct attr_stack *read_attr_from_array(const char **list)
300
a = parse_attr_line(line, "[builtin]", ++lineno, 1);
301
if (!a)
302
continue;
303
- res->attrs = xrealloc(res->attrs, res->num_matches + 1);
303
+ res->attrs = xrealloc(res->attrs,
304
+ sizeof(struct match_attr *) * (res->num_matches + 1));
305
res->attrs[res->num_matches++] = a;
306
}
307
return res;
@@ -324,7 +325,8 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
325
a = parse_attr_line(buf, path, ++lineno, macro_ok);
326
if (!a)
327
continue;
327
- res->attrs = xrealloc(res->attrs, res->num_matches + 1);
328
+ res->attrs = xrealloc(res->attrs,
329
+ sizeof(struct match_attr *) * (res->num_matches + 1));
330
res->attrs[res->num_matches++] = a;
331
}
332
fclose(fp);