Skip to content

Commit 42e298f

Browse files
committed
Merge branch 'codeql-fixes'
CodeQL pointed out a couple of issues, which are addressed in this patch series. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents f793bf8 + a1bef6c commit 42e298f

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

builtin/fetch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,6 +2551,11 @@ int cmd_fetch(int argc,
25512551
die(_("must supply remote when using --negotiate-only"));
25522552
gtransport = prepare_transport(remote, 1);
25532553
if (gtransport->smart_options) {
2554+
/*
2555+
* Intentionally assign the address of a local variable
2556+
* to a non-local struct's field.
2557+
* codeql[cpp/stack-address-escape]
2558+
*/
25542559
gtransport->smart_options->acked_commits = &acked_commits;
25552560
} else {
25562561
warning(_("protocol does not support --negotiate-only, exiting"));

builtin/submodule--helper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,9 @@ static int determine_submodule_update_strategy(struct repository *r,
19341934
const char *val;
19351935
int ret;
19361936

1937+
if (!sub)
1938+
return error(_("could not retrieve submodule information for path '%s'"), path);
1939+
19371940
key = xstrfmt("submodule.%s.update", sub->name);
19381941

19391942
if (update) {

commit-graph.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,6 +2560,7 @@ int write_commit_graph(struct object_directory *odb,
25602560
struct commit_graph *g = ctx.r->objects->commit_graph;
25612561

25622562
while (g) {
2563+
/* Intentional: codeql[cpp/stack-address-escape] */
25632564
g->topo_levels = &topo_levels;
25642565
g = g->base_graph;
25652566
}

shallow.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
705705
for (i = 0; i < nr_shallow; i++) {
706706
struct commit *c = lookup_commit(the_repository,
707707
&oid[shallow[i]]);
708-
c->object.flags |= BOTTOM;
708+
if (c)
709+
c->object.flags |= BOTTOM;
709710
}
710711

711712
for (i = 0; i < ref->nr; i++)

t/helper/test-repository.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
2727
repo_set_hash_algo(the_repository, hash_algo_by_ptr(r.hash_algo));
2828

2929
c = lookup_commit(&r, commit_oid);
30+
if (!c)
31+
die("Could not look up %s", oid_to_hex(commit_oid));
3032

3133
if (!parse_commit_in_graph(&r, c))
3234
die("Couldn't parse commit");

0 commit comments

Comments
 (0)