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

Re: [PATCH 1/3] refs/packed-backend.c: close fd of empty file

From
Jeff King <peff@peff.net>
Date
May 31, 2018, 05:15 UTC
Message-ID
<20180531051546.GA17068@sigill.intra.peff.net>
In-Reply-To
<20180530170302.191176-1-sbeller@google.com>
On Wed, May 30, 2018 at 10:03:00AM -0700, Stefan Beller wrote:
Show 12 quoted lines
> diff --git a/refs/packed-backend.c b/refs/packed-backend.c
> index cec3fb9e00f..d447a731da0 100644
> --- a/refs/packed-backend.c
> +++ b/refs/packed-backend.c
> @@ -499,6 +499,7 @@ static int load_contents(struct snapshot *snapshot)
>  	size = xsize_t(st.st_size);
>  
>  	if (!size) {
> +		close(fd);
>  		return 0;
>  	} else if (mmap_strategy == MMAP_NONE || size <= SMALL_FILE_SIZE) {
>  		snapshot->buf = xmalloc(size);
Yep, this is definitely correct. Good catch.
-Peff
Previous: Johannes SchindelinNext: Michael Haggerty
Message 9 of 11 in “refs/packed-backend.c: close fd of empty file”
  1. 1/3 refs/packed-backend.c: close fd of empty fileStefan Beller, May 30, 2018
  2. 2/3 sequencer.c: free author variable when merging failsStefan Beller, May 30, 2018
  3. Johannes SchindelinMay 31, 2018
  4. Stefan BellerMay 31, 2018
  5. 3/3 submodule--helper: plug mem leak in print_default_remoteStefan Beller, May 30, 2018
  6. Johannes SchindelinMay 31, 2018
  7. Stefan BellerMay 31, 2018
  8. Johannes SchindelinJun 1, 2018
  9. Jeff KingMay 31, 2018
  10. Michael HaggertyMay 31, 2018
  11. Johannes SchindelinMay 31, 2018

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.