]> git.ipfire.org Git - thirdparty/git.git/commit
remote: guard `remote_tracking()` against NULL remote
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 10 Jul 2026 11:39:27 +0000 (11:39 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jul 2026 15:13:54 +0000 (08:13 -0700)
commit2fdcce115a5ce4fe3d025858f958b92ab1c4d20e
tree9fdd449e0c499dfd4ecb7af87083cf3f4bdc9317
parentd07d09ee43b920f17d00a96ee29621e398136218
remote: guard `remote_tracking()` against NULL remote

The `remote_tracking()` function unconditionally dereferences
`remote->fetch` without checking whether remote is NULL.

In practice, this never happens because the only caller (`apply_cas()`)
guards the calls to this function by checking the `use_tracking` and
`use_tracking_for_rest` attributes.

However, it requires quite involved reasoning to reach that conclusion,
and is therefore fragile. Just return -1 ("no tracking ref") when there
is no remote to work with.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c