git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] refs.c: release file descriptor on error return

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Jul 16, 2009, 21:25 UTC
Message-ID
<W0GiRm9n1NEfjVB8xBotapRpIoR0jr6qkttRpkkGMPpe-bfqtvLM7YBvkMsGo7-vheQxRPBUAEU@cipher.nrlssc.navy.mil>
In-Reply-To
<W0GiRm9n1NEfjVB8xBotanSRY89hxjLPu3Wksn_EsZusMJjkHNIRf8JuQmUh43ny21xTKBn1Li8@cipher.nrlssc.navy.mil>
From: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 refs.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/refs.c b/refs.c
index dffe395..e15880f 100644
--- a/refs.c
+++ b/refs.c
@@ -1525,8 +1525,10 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs,
 		if (fstat(fileno(logfp), &statbuf) ||
 		    statbuf.st_size < ofs ||
 		    fseek(logfp, -ofs, SEEK_END) ||
-		    fgets(buf, sizeof(buf), logfp))
+		    fgets(buf, sizeof(buf), logfp)) {
+			fclose(logfp);
 			return -1;
+		}
 	}
 
 	while (fgets(buf, sizeof(buf), logfp)) {
-- 
1.6.3.1.24.g152f4
Previous: Brandon CaseyNext: Brandon Casey
Message 2 of 3 in “Two miscellaneous patches found while debugging 'next'”
  1. 0/2 Two miscellaneous patches found while debugging 'next'Brandon Casey, Jul 16, 2009
  2. 1/2 refs.c: release file descriptor on error returnBrandon Casey, Jul 16, 2009
  3. 2/2 sha1_name.c: avoid unnecessary strbuf_releaseBrandon Casey, Jul 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.