{"thread":{"id":"10968","subject":"[PATCH] For the sake of correctness, fix file descriptor leak.","startedAt":"2007-11-22T00:59:16Z","lastAt":"2007-11-25T22:29:07Z","messageCount":3,"participants":["André Goddard Rosa","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"60587","messageId":"b8bf37780711211659v4fbd5936t29d0a0a2ff84f4b@mail.gmail.com","threadId":"10968","inReplyTo":null,"subject":"[PATCH] For the sake of correctness, fix file descriptor leak.","fromName":"André Goddard Rosa","fromEmail":"andre.goddard@gmail.com","sentAt":"2007-11-22T00:59:16Z","receivedAt":"2007-11-22T00:59:16Z","isPatch":true,"sender":{"key":"andre.goddard@gmail.com","avatar":null},"body":"Hi, all!\n\n    Please cc: me as I'm not subscribed. I'm sending the patch inline\nonly for review, probably it is mangled.\n    Please use the attached patch if you agree with it. Sorry about\nsending it attached.\n\n>From 9fba346aca7470633ee46848013051248493896c Mon Sep 17 00:00:00 2001\nFrom: Andre Goddard Rosa <andre.goddard@gmail.com>\nDate: Tue, 27 Nov 2007 10:16:22 -0200\nSubject: [PATCH] For the sake of correctness, fix file descriptor leak.\n\nSigned-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>\n---\n builtin-rerere.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-rerere.c b/builtin-rerere.c\nindex 7449323..31766be 100644\n--- a/builtin-rerere.c\n+++ b/builtin-rerere.c\n@@ -275,8 +275,10 @@ static int copy_file(const char *src, const char *dest)\n\n \tif (!(in = fopen(src, \"r\")))\n \t\treturn error(\"Could not open %s\", src);\n-\tif (!(out = fopen(dest, \"w\")))\n+\tif (!(out = fopen(dest, \"w\"))) {\n+\t\tfclose(in);\n \t\treturn error(\"Could not open %s\", dest);\n+\t}\n \twhile ((count = fread(buffer, 1, sizeof(buffer), in)))\n \t\tfwrite(buffer, 1, count, out);\n \tfclose(in);\n-- \n1.5.3.6.861.gd794-dirty\n\n\nFrom 9fba346aca7470633ee46848013051248493896c Mon Sep 17 00:00:00 2001\nFrom: Andre Goddard Rosa <andre.goddard@gmail.com>\nDate: Tue, 27 Nov 2007 10:16:22 -0200\nSubject: [PATCH] For the sake of correctness, fix file descriptor leak.\n\nSigned-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>\n---\n builtin-rerere.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-rerere.c b/builtin-rerere.c\nindex 7449323..31766be 100644\n--- a/builtin-rerere.c\n+++ b/builtin-rerere.c\n@@ -275,8 +275,10 @@ static int copy_file(const char *src, const char *dest)\n \n \tif (!(in = fopen(src, \"r\")))\n \t\treturn error(\"Could not open %s\", src);\n-\tif (!(out = fopen(dest, \"w\")))\n+\tif (!(out = fopen(dest, \"w\"))) {\n+\t\tfclose(in);\n \t\treturn error(\"Could not open %s\", dest);\n+\t}\n \twhile ((count = fread(buffer, 1, sizeof(buffer), in)))\n \t\tfwrite(buffer, 1, count, out);\n \tfclose(in);\n-- \n1.5.3.6.861.gd794-dirty\n\n"},{"id":"60869","messageId":"b8bf37780711251337q41e02304q8fd2654b1e83201@mail.gmail.com","threadId":"10968","inReplyTo":"b8bf37780711211659v4fbd5936t29d0a0a2ff84f4b@mail.gmail.com","subject":"[Resend Trivial PATCH] For the sake of correctness, fix file descriptor leak.","fromName":"André Goddard Rosa","fromEmail":"andre.goddard@gmail.com","sentAt":"2007-11-25T21:37:05Z","receivedAt":"2007-11-25T21:37:05Z","isPatch":true,"sender":{"key":"andre.goddard@gmail.com","avatar":null},"body":"Hi, all!\n\n    Plug a file descriptor leak.\n\nFrom 9fba346aca7470633ee46848013051248493896c Mon Sep 17 00:00:00 2001\nFrom: Andre Goddard Rosa <andre.goddard@gmail.com>\nDate: Tue, 27 Nov 2007 10:16:22 -0200\nSubject: [PATCH] For the sake of correctness, fix file descriptor leak.\n\nSigned-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>\n---\n builtin-rerere.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-rerere.c b/builtin-rerere.c\nindex 7449323..31766be 100644\n--- a/builtin-rerere.c\n+++ b/builtin-rerere.c\n@@ -275,8 +275,10 @@ static int copy_file(const char *src, const char *dest)\n\n        if (!(in = fopen(src, \"r\")))\n                return error(\"Could not open %s\", src);\n-       if (!(out = fopen(dest, \"w\")))\n+       if (!(out = fopen(dest, \"w\"))) {\n+               fclose(in);\n                return error(\"Could not open %s\", dest);\n+       }\n        while ((count = fread(buffer, 1, sizeof(buffer), in)))\n                fwrite(buffer, 1, count, out);\n        fclose(in);\n--\n1.5.3.6.861.gd794-dirty\n\n\n\n-- \n[]s,\nAndré Goddard\n\n\nFrom 9fba346aca7470633ee46848013051248493896c Mon Sep 17 00:00:00 2001\nFrom: Andre Goddard Rosa <andre.goddard@gmail.com>\nDate: Tue, 27 Nov 2007 10:16:22 -0200\nSubject: [PATCH] For the sake of correctness, fix file descriptor leak.\n\nSigned-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>\n---\n builtin-rerere.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-rerere.c b/builtin-rerere.c\nindex 7449323..31766be 100644\n--- a/builtin-rerere.c\n+++ b/builtin-rerere.c\n@@ -275,8 +275,10 @@ static int copy_file(const char *src, const char *dest)\n \n \tif (!(in = fopen(src, \"r\")))\n \t\treturn error(\"Could not open %s\", src);\n-\tif (!(out = fopen(dest, \"w\")))\n+\tif (!(out = fopen(dest, \"w\"))) {\n+\t\tfclose(in);\n \t\treturn error(\"Could not open %s\", dest);\n+\t}\n \twhile ((count = fread(buffer, 1, sizeof(buffer), in)))\n \t\tfwrite(buffer, 1, count, out);\n \tfclose(in);\n-- \n1.5.3.6.861.gd794-dirty\n\n"},{"id":"60882","messageId":"7vbq9ij6x8.fsf@gitster.siamese.dyndns.org","threadId":"10968","inReplyTo":"b8bf37780711251337q41e02304q8fd2654b1e83201@mail.gmail.com","subject":"Re: [Resend Trivial PATCH] For the sake of correctness, fix file descriptor leak.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-25T22:29:07Z","receivedAt":"2007-11-25T22:29:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The codepath you are touching will exit immediately after an error\nreturn; I do not feel much urgency to it, although I do not think the\npatch would _hurt_.\n\nPlease follow the established convention for patch submission (see\npatches on the list from other people as examples).\n"}]}