{"thread":{"id":"7778","subject":"[PATCH] Fix crash in t0020 (crlf conversion)","startedAt":"2007-04-22T14:11:54Z","lastAt":"2007-04-22T14:11:54Z","messageCount":1,"participants":["Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40117","messageId":"20070422141154.GB2431@steel.home","threadId":"7778","inReplyTo":null,"subject":"[PATCH] Fix crash in t0020 (crlf conversion)","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-22T14:11:54Z","receivedAt":"2007-04-22T14:11:54Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Reallocated wrong size.\nNoticed on Ubuntu 7.04 probably because it has some malloc diagnostics in libc:\n\"git-read-tree --reset -u HEAD\" aborted in the test. Valgrind sped up the\ndebugging greatly: took me 10 minutes.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n attr.c |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 285e689..a071254 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -300,7 +300,8 @@ static struct attr_stack *read_attr_from_array(const char **list)\n \t\ta = parse_attr_line(line, \"[builtin]\", ++lineno, 1);\n \t\tif (!a)\n \t\t\tcontinue;\n-\t\tres->attrs = xrealloc(res->attrs, res->num_matches + 1);\n+\t\tres->attrs = xrealloc(res->attrs,\n+\t\t\tsizeof(struct match_attr *) * (res->num_matches + 1));\n \t\tres->attrs[res->num_matches++] = a;\n \t}\n \treturn res;\n@@ -324,7 +325,8 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)\n \t\ta = parse_attr_line(buf, path, ++lineno, macro_ok);\n \t\tif (!a)\n \t\t\tcontinue;\n-\t\tres->attrs = xrealloc(res->attrs, res->num_matches + 1);\n+\t\tres->attrs = xrealloc(res->attrs,\n+\t\t\tsizeof(struct match_attr *) * (res->num_matches + 1));\n \t\tres->attrs[res->num_matches++] = a;\n \t}\n \tfclose(fp);\n-- \n1.5.1.1.946.gdb75a\n"}]}