{"thread":{"id":"32258","subject":"Also close config file handle when leaving git_config_set_multivar_in_file() early","startedAt":"2012-12-01T14:01:51Z","lastAt":"2012-12-01T14:01:51Z","messageCount":1,"participants":["乙酸鋰"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"204384","messageId":"CAHtLG6SDb5t3ABttbCi5=nVsygf5gLw9DzVtZt0L3WMPNECBWQ@mail.gmail.com","threadId":"32258","inReplyTo":null,"subject":"Also close config file handle when leaving git_config_set_multivar_in_file() early","fromName":"乙酸鋰","fromEmail":"ch3cooli@gmail.com","sentAt":"2012-12-01T14:01:51Z","receivedAt":"2012-12-01T14:01:51Z","isPatch":false,"sender":{"key":"ch3cooli@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2804967?v=4"},"body":"Hi,\n\nThis patch fixes the captioned problem.\nIt is needed because our program statically link git.\nIn this case, do not assume a fail will call die() and exit program so\nthe handle is leave not closed.\n\nRegards,\nch3cooli\n\n\nFrom 5d8d28f039b4db7b4f040a40fdc2edf866200f0c Mon Sep 17 00:00:00 2001\nFrom: Sup Yut Sum <ch3cooli@gmail.com>\nDate: Sat, 1 Dec 2012 21:56:41 +0800\nSubject: [PATCH] Also close config file handle when leaving\n git_config_set_multivar_in_file() early\n\nSigned-off-by: Sup Yut Sum <ch3cooli@gmail.com>\n---\n config.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/config.c b/config.c\nindex fff8a43..4b5c877 100644\n--- a/config.c\n+++ b/config.c\n@@ -1424,6 +1424,7 @@ int git_config_set_multivar_in_file(const char *config_filename,\n \t\tcontents = xmmap(NULL, contents_sz, PROT_READ,\n \t\t\tMAP_PRIVATE, in_fd, 0);\n \t\tclose(in_fd);\n+\t\tin_fd = -1;\n \n \t\tif (store.seen == 0)\n \t\t\tstore.seen = 1;\n@@ -1493,6 +1494,8 @@ out_free:\n \tif (lock)\n \t\trollback_lock_file(lock);\n \tfree(filename_buf);\n+\tif (in_fd >= 0)\n+\t\tclose(in_fd);\n \treturn ret;\n \n write_err_out:\n-- \n1.8.0.msysgit.0\n\n"}]}