{"thread":{"id":"29835","subject":"[PATCH] fast-import: zero all of 'struct tag' to silence valgrind","startedAt":"2012-03-05T13:48:49Z","lastAt":"2012-03-05T13:48:49Z","messageCount":1,"participants":["Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"186108","messageId":"f95bf5b4fb814e9c83df96604526dd48d13f1abc.1330955283.git.trast@student.ethz.ch","threadId":"29835","inReplyTo":null,"subject":"[PATCH] fast-import: zero all of 'struct tag' to silence valgrind","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2012-03-05T13:48:49Z","receivedAt":"2012-03-05T13:48:49Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"When running t9300, valgrind (correctly) complains about an\nuninitialized value in write_crash_report:\n\n  ==2971== Use of uninitialised value of size 8\n  ==2971==    at 0x4164F4: sha1_to_hex (hex.c:70)\n  ==2971==    by 0x4073E4: die_nicely (fast-import.c:468)\n  ==2971==    by 0x43284C: die (usage.c:86)\n  ==2971==    by 0x40420D: main (fast-import.c:2731)\n  ==2971==  Uninitialised value was created by a heap allocation\n  ==2971==    at 0x4C29B3D: malloc (vg_replace_malloc.c:263)\n  ==2971==    by 0x433645: xmalloc (wrapper.c:35)\n  ==2971==    by 0x405DF5: pool_alloc (fast-import.c:619)\n  ==2971==    by 0x407755: pool_calloc.constprop.14 (fast-import.c:634)\n  ==2971==    by 0x403F33: main (fast-import.c:3324)\n\nFix this by zeroing all of the 'struct tag'.  We would only need to\nzero out the 'sha1' field, but this way seems more future-proof.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n fast-import.c |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 6cd19e5..c1486ca 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2712,7 +2712,7 @@ static void parse_new_tag(void)\n \t/* Obtain the new tag name from the rest of our command */\n \tsp = strchr(command_buf.buf, ' ') + 1;\n \tt = pool_alloc(sizeof(struct tag));\n-\tt->next_tag = NULL;\n+\tmemset(t, 0, sizeof(struct tag));\n \tt->name = pool_strdup(sp);\n \tif (last_tag)\n \t\tlast_tag->next_tag = t;\n-- \n1.7.9.2.467.g7fee4\n"}]}