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

[PATCH] Fix resource leaks in wrapper.c

From
LPLaszlo Papp <djszapi2@gmail.com>
Date
Oct 27, 2009, 03:53 UTC
Message-ID
<1256615635-4940-1-git-send-email-djszapi@archlinux.us>
Fix the following issues with the desired close tags:

[wrapper.c:276]: (error) Resource leak: fd [wrapper.c:291]: (error) Resource leak: fd

Signed-off-by: Laszlo Papp <djszapi@archlinux.us>
---
 wrapper.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/wrapper.c b/wrapper.c
index c9be140..76ecf0a 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -266,7 +266,7 @@ int odb_mkstemp(char *template, size_t limit, const char *pattern)
 	fd = mkstemp(template);
 	if (0 <= fd)
 		return fd;
-
+	close(fd);
 	/* slow path */
 	/* some mkstemp implementations erase template on failure */
 	snprintf(template, limit, "%s/%s",
@@ -284,7 +284,7 @@ int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1)
 	fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
 	if (0 <= fd)
 		return fd;
-
+	close(fd);
 	/* slow path */
 	safe_create_leading_directories(name);
 	return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
-- 
1.6.5
Next: Johannes Sixt
Message 1 of 4 in “Fix resource leaks in wrapper.c”
  1. Fix resource leaks in wrapper.cLaszlo Papp, Oct 27, 2009
  2. Johannes SixtOct 27, 2009
  3. Michael J GruberOct 27, 2009
  4. Michael J GruberOct 27, 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.