)]}'
{
  "commit": "aa1b63971ab4e7d1f603c87f2137605249580272",
  "tree": "5672bb5033ea50c2f23839c48871b846988107c4",
  "parents": [
    "0c4542738e626b7af12bcc13673964c98a6eb68b"
  ],
  "author": {
    "name": "Andrzej Hunt",
    "email": "ajrhunt@google.com",
    "time": "Sun Mar 14 18:47:37 2021 +0000"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Sun Mar 14 15:57:59 2021 -0700"
  },
  "message": "worktree: fix leak in dwim_branch()\n\nMake sure that we release the temporary strbuf during dwim_branch() for\nall codepaths (and not just for the early return).\n\nThis leak appears to have been introduced in:\n  f60a7b763f (worktree: teach \"add\" to check out existing branches, 2018-04-24)\n\nNote that UNLEAK(branchname) is still needed: the returned result is\nused in add(), and is stored in a pointer which is used to point at one\nof:\n  - a string literal (\"HEAD\")\n  - member of argv (whatever the user specified in their invocation)\n  - or our newly allocated string returned from dwim_branch()\nFixing the branchname leak isn\u0027t impossible, but does not seem\nworthwhile given that add() is called directly from cmd_main(), and\ncmd_main() returns immediately thereafter - UNLEAK is good enough.\n\nThis leak was found when running t0001 with LSAN, see also LSAN output\nbelow:\n\nDirect leak of 60 byte(s) in 1 object(s) allocated from:\n    #0 0x49a859 in realloc /home/abuild/rpmbuild/BUILD/llvm-11.0.0.src/build/../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:164:3\n    #1 0x9ab076 in xrealloc /home/ahunt/oss-fuzz/git/wrapper.c:126:8\n    #2 0x939fcd in strbuf_grow /home/ahunt/oss-fuzz/git/strbuf.c:98:2\n    #3 0x93af53 in strbuf_splice /home/ahunt/oss-fuzz/git/strbuf.c:239:3\n    #4 0x83559a in strbuf_check_branch_ref /home/ahunt/oss-fuzz/git/object-name.c:1593:2\n    #5 0x6988b9 in dwim_branch /home/ahunt/oss-fuzz/git/builtin/worktree.c:454:20\n    #6 0x695f8f in add /home/ahunt/oss-fuzz/git/builtin/worktree.c:525:19\n    #7 0x694a04 in cmd_worktree /home/ahunt/oss-fuzz/git/builtin/worktree.c:1036:10\n    #8 0x4cd60d in run_builtin /home/ahunt/oss-fuzz/git/git.c:453:11\n    #9 0x4cb2da in handle_builtin /home/ahunt/oss-fuzz/git/git.c:704:3\n    #10 0x4ccc37 in run_argv /home/ahunt/oss-fuzz/git/git.c:771:4\n    #11 0x4cac29 in cmd_main /home/ahunt/oss-fuzz/git/git.c:902:19\n    #12 0x69caee in main /home/ahunt/oss-fuzz/git/common-main.c:52:11\n    #13 0x7f7b7dd10349 in __libc_start_main (/lib64/libc.so.6+0x24349)\n\nSigned-off-by: Andrzej Hunt \u003cajrhunt@google.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "1cd5c2016e3f90f4f2da15bad4a1be7038db327b",
      "old_mode": 33188,
      "old_path": "builtin/worktree.c",
      "new_id": "87714534938189f8dc25ba112bb660ee5e7f60ee",
      "new_mode": 33188,
      "new_path": "builtin/worktree.c"
    }
  ]
}
