{"thread":{"id":"39991","subject":"[PATCH] transport-helper: die on errors reading refs.","startedAt":"2015-07-31T23:57:57Z","lastAt":"2015-07-31T23:57:57Z","messageCount":1,"participants":["Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"267249","messageId":"1438387077-10181-1-git-send-email-sbeller@google.com","threadId":"39991","inReplyTo":null,"subject":"[PATCH] transport-helper: die on errors reading refs.","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-07-31T23:57:57Z","receivedAt":"2015-07-31T23:57:57Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"We check the return value of read_ref in 19 out of 21 cases.\nThis adds checks to the missing cases.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n transport-helper.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 5d99a6b..68e498e 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -490,7 +490,8 @@ static int fetch_with_import(struct transport *transport,\n \t\telse\n \t\t\tprivate = xstrdup(name);\n \t\tif (private) {\n-\t\t\tread_ref(private, posn->old_sha1);\n+\t\t\tif (read_ref(private, posn->old_sha1) < 0)\n+\t\t\t\tdie(\"Could not read ref %s\", private);\n \t\t\tfree(private);\n \t\t}\n \t}\n@@ -1019,7 +1020,10 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)\n \t\tif (eon) {\n \t\t\tif (has_attribute(eon + 1, \"unchanged\")) {\n \t\t\t\t(*tail)->status |= REF_STATUS_UPTODATE;\n-\t\t\t\tread_ref((*tail)->name, (*tail)->old_sha1);\n+\t\t\t\tif (read_ref((*tail)->name,\n+\t\t\t\t\t     (*tail)->old_sha1) < 0)\n+\t\t\t\t\tdie(N_(\"Could not read ref %s\"),\n+\t\t\t\t\t    (*tail)->name);\n \t\t\t}\n \t\t}\n \t\ttail = &((*tail)->next);\n-- \n2.5.0.5.gf4cd9ae.dirty\n"}]}