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

[PATCH 00/13] coverity: fix leaks and error paths

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 1, 2026, 07:04 UTC
Message-ID
<pull.2163.git.1782889472.gitgitgadget@gmail.com>

I wanted to whittle down the many issues reported by Coverity in the Git for Windows project. Turns out: The vast majority of the issues are false positives. Most of the remaining issues are in core Git proper.

This effort was forced on pause while Coverity was down from May 16 [https://web.archive.org/web/20260516152422/https://scan.coverity.com/] to June 22 [https://web.archive.org/web/20260622182153/https://scan.coverity.com/]).

Here is a first batch of fixes for those issues.
Johannes Schindelin (13):
  load_one_loose_object_map(): fix resource leak
  loose: avoid closing invalid fd on error path
  download_https_uri_to_file(): do not leak fd upon failure
  run-command: avoid close(-1) in start_command() error paths
  run_diff_files: avoid memory leak
  line-log: avoid redundant copy that leaks in process_ranges
  dir: free allocations on parse-error paths in read_one_dir()
  submodule: fix cwd leak in get_superproject_working_tree()
  worktree: fix resource leaks when branch creation fails
  imap-send: avoid leaking the IMAP upload buffer
  reftable/table: release filter on error path
  fsmonitor: plug token-data leak on early daemon-startup failures
  mingw: make exit_process() own the process handle on all paths
 builtin/fsmonitor--daemon.c |  2 ++
 builtin/worktree.c          |  7 +++++--
 bundle-uri.c                |  2 +-
 compat/mingw.c              |  4 +---
 compat/win32/exit-process.h |  1 +
 diff-lib.c                  |  3 ++-
 dir.c                       |  9 +++++++--
 imap-send.c                 |  1 +
 line-log.c                  |  3 +--
 loose.c                     | 11 ++++++-----
 reftable/table.c            |  4 ++++
 run-command.c               |  6 +++---
 submodule.c                 |  8 ++++++--
 13 files changed, 40 insertions(+), 21 deletions(-)
base-commit: e9019fcafe0040228b8631c30f97ae1adb61bcdc
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2163%2Fdscho%2Fcoverity-fixes-leaks-and-error-paths-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2163/dscho/coverity-fixes-leaks-and-error-paths-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2163
-- 
gitgitgadget
Next: Johannes Schindelin via GitGitGadget
Message 1 of 44 in “coverity: fix leaks and error paths”
  1. 00/13 coverity: fix leaks and error pathsJohannes Schindelin via GitGitGadget, Jul 1, 2026
  2. 01/13 load_one_loose_object_map(): fix resource leakJohannes Schindelin via GitGitGadget, Jul 1, 2026
  3. Patrick SteinhardtJul 1, 2026
  4. Junio C HamanoJul 1, 2026
  5. Johannes SchindelinJul 4, 2026
  6. 02/13 loose: avoid closing invalid fd on error pathJohannes Schindelin via GitGitGadget, Jul 1, 2026
  7. Patrick SteinhardtJul 1, 2026
  8. 03/13 download_https_uri_to_file(): do not leak fd upon failureJohannes Schindelin via GitGitGadget, Jul 1, 2026
  9. 04/13 run-command: avoid close(-1) in start_command() error pathsJohannes Schindelin via GitGitGadget, Jul 1, 2026
  10. Patrick SteinhardtJul 1, 2026
  11. 05/13 run_diff_files: avoid memory leakJohannes Schindelin via GitGitGadget, Jul 1, 2026
  12. Patrick SteinhardtJul 1, 2026
  13. Johannes SchindelinJul 4, 2026
  14. 06/13 line-log: avoid redundant copy that leaks in process_rangesJohannes Schindelin via GitGitGadget, Jul 1, 2026
  15. Jeff KingJul 1, 2026
  16. 07/13 dir: free allocations on parse-error paths in read_one_dir()Johannes Schindelin via GitGitGadget, Jul 1, 2026
  17. Patrick SteinhardtJul 1, 2026
  18. Johannes SchindelinJul 4, 2026
  19. 08/13 submodule: fix cwd leak in get_superproject_working_tree()Johannes Schindelin via GitGitGadget, Jul 1, 2026
  20. Patrick SteinhardtJul 1, 2026
  21. Johannes SchindelinJul 4, 2026
  22. 09/13 worktree: fix resource leaks when branch creation failsJohannes Schindelin via GitGitGadget, Jul 1, 2026
  23. 10/13 imap-send: avoid leaking the IMAP upload bufferJohannes Schindelin via GitGitGadget, Jul 1, 2026
  24. 11/13 reftable/table: release filter on error pathJohannes Schindelin via GitGitGadget, Jul 1, 2026
  25. 12/13 fsmonitor: plug token-data leak on early daemon-startup failuresJohannes Schindelin via GitGitGadget, Jul 1, 2026
  26. 13/13 mingw: make exit_process() own the process handle on all pathsJohannes Schindelin via GitGitGadget, Jul 1, 2026
  27. Junio C HamanoJul 1, 2026
  28. 00/12 coverity: fix leaks and error pathsJohannes Schindelin via GitGitGadget, Jul 5, 2026
  29. 01/12 load_one_loose_object_map(): fix resource leakJohannes Schindelin via GitGitGadget, Jul 5, 2026
  30. Patrick SteinhardtJul 7, 2026
  31. 02/12 loose: avoid closing invalid fd on error pathJohannes Schindelin via GitGitGadget, Jul 5, 2026
  32. 03/12 download_https_uri_to_file(): do not leak fd upon failureJohannes Schindelin via GitGitGadget, Jul 5, 2026
  33. 04/12 run-command: avoid `close(-1)` in `start_command()` error pathsJohannes Schindelin via GitGitGadget, Jul 5, 2026
  34. 05/12 line-log: avoid redundant copy that leaks in process_rangesJohannes Schindelin via GitGitGadget, Jul 5, 2026
  35. 06/12 dir: free allocations on parse-error paths in `read_one_dir()`Johannes Schindelin via GitGitGadget, Jul 5, 2026
  36. 07/12 submodule: fix cwd leak in `get_superproject_working_tree()`Johannes Schindelin via GitGitGadget, Jul 5, 2026
  37. Patrick SteinhardtJul 7, 2026
  38. 08/12 worktree: fix resource leaks when branch creation failsJohannes Schindelin via GitGitGadget, Jul 5, 2026
  39. 09/12 imap-send: avoid leaking the IMAP upload bufferJohannes Schindelin via GitGitGadget, Jul 5, 2026
  40. 10/12 reftable/table: release filter on error pathJohannes Schindelin via GitGitGadget, Jul 5, 2026
  41. 11/12 fsmonitor: plug token-data leak on early daemon-startup failuresJohannes Schindelin via GitGitGadget, Jul 5, 2026
  42. 12/12 mingw: make `exit_process()` own the process handle on all pathsJohannes Schindelin via GitGitGadget, Jul 5, 2026
  43. Patrick SteinhardtJul 7, 2026
  44. Junio C HamanoJul 7, 2026

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.