From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 09/14] fetch: defensive programming
Date: Thu, 15 May 2025 12:45:34 +0000 [thread overview]
Message-ID: <d8397662bcf72445dd06a09a6615b066c9166cf4.1747313140.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1890.git.1747313139.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
CodeQL points out that `branch_get()` can return NULL values.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
builtin/fetch.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 95fd0018b981..e7523c531407 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -553,7 +553,7 @@ static struct ref *get_ref_map(struct remote *remote,
if (remote &&
(remote->fetch.nr ||
/* Note: has_merge implies non-NULL branch->remote_name */
- (has_merge && !strcmp(branch->remote_name, remote->name)))) {
+ (has_merge && branch && !strcmp(branch->remote_name, remote->name)))) {
for (i = 0; i < remote->fetch.nr; i++) {
get_fetch_map(remote_refs, &remote->fetch.items[i], &tail, 0);
if (remote->fetch.items[i].dst &&
@@ -571,6 +571,7 @@ static struct ref *get_ref_map(struct remote *remote,
* Note: has_merge implies non-NULL branch->remote_name
*/
if (has_merge &&
+ branch &&
!strcmp(branch->remote_name, remote->name))
add_merge_config(&ref_map, remote_refs, branch, &tail);
} else if (!prefetch) {
--
gitgitgadget
next prev parent reply other threads:[~2025-05-15 12:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 12:45 [PATCH 00/14] Some defensive programming Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 01/14] revision: " Johannes Schindelin via GitGitGadget
2025-05-15 17:13 ` Junio C Hamano
2025-05-15 12:45 ` [PATCH 02/14] get_parent(): " Johannes Schindelin via GitGitGadget
2025-05-15 17:21 ` Junio C Hamano
2025-05-15 20:32 ` Jeff King
2025-05-15 12:45 ` [PATCH 03/14] fetch-pack: " Johannes Schindelin via GitGitGadget
2025-05-15 17:24 ` Junio C Hamano
2025-05-15 12:45 ` [PATCH 04/14] unparse_commit(): " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 05/14] verify_commit_graph(): " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 06/14] stash: " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 07/14] " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 08/14] push: " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` Johannes Schindelin via GitGitGadget [this message]
2025-05-15 12:45 ` [PATCH 10/14] describe: " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 11/14] inherit_tracking(): " Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 12/14] submodule: check return value of `submodule_from_path()` Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 13/14] test-tool repository: check return value of `lookup_commit()` Johannes Schindelin via GitGitGadget
2025-05-15 12:45 ` [PATCH 14/14] shallow: handle missing shallow commits gracefully Johannes Schindelin via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d8397662bcf72445dd06a09a6615b066c9166cf4.1747313140.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).