{"thread":{"id":"8577","subject":"[PATCH] Don't dereference a strdup-returned NULL","startedAt":"2007-06-12T20:59:21Z","lastAt":"2007-06-12T20:59:21Z","messageCount":1,"participants":["Jim Meyering"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"44871","messageId":"87abv4ubx2.fsf@rho.meyering.net","threadId":"8577","inReplyTo":null,"subject":"[PATCH] Don't dereference a strdup-returned NULL","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2007-06-12T20:59:21Z","receivedAt":"2007-06-12T20:59:21Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"There are only a dozen or so uses of strdup in all of git.\nOf those, most seem ok, but this one isn't:\n\nSigned-off-by: Jim Meyering <jim@meyering.net>\n---\n remote.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex 33c8e50..ed62a62 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -542,7 +542,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,\n \t\t\tstrcpy(dst_name, pat->dst);\n \t\t\tstrcat(dst_name, src->name + strlen(pat->src));\n \t\t} else\n-\t\t\tdst_name = strdup(src->name);\n+\t\t\tdst_name = xstrdup(src->name);\n \t\tdst_peer = find_ref_by_name(dst, dst_name);\n \t\tif (dst_peer && dst_peer->peer_ref)\n \t\t\t/* We're already sending something to this ref. */\n--\n1.5.2.1.159.g8d11\n"}]}