]> git.99rst.org Git - git.git/commit
submodule: fix cwd leak in `get_superproject_working_tree()`
authorJohannes Schindelin <redacted>
Sun, 5 Jul 2026 08:24:24 +0000 (08:24 +0000)
committerJunio C Hamano <redacted>
Sun, 5 Jul 2026 16:12:10 +0000 (09:12 -0700)
commitadd15d11ac1d882fe1a36e3f7a936fb92943ecca
treeba8740ae1dee88ed29945ea1d74c94c3737ff35e
parent6eb60059bd6d852d41c5e5c43bf5b033abbfca3b
submodule: fix cwd leak in `get_superproject_working_tree()`

`get_superproject_working_tree()` allocates cwd via `xgetcwd()` at the
top of the function, but two early-return paths (when not inside a work
tree, and when strbuf_realpath for "../" fails) return 0 without freeing
it.

Redirect these early returns through a cleanup label that frees cwd
before returning.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
submodule.c
git clone https://git.99rst.org/PROJECT