Skip to content

Commit 61f757b

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 c5449c0 + c25505f commit 61f757b

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
@@ -2568,6 +2568,11 @@ int cmd_fetch(int argc,
25682568
die(_("must supply remote when using --negotiate-only"));
25692569
gtransport = prepare_transport(remote, 1);
25702570
if (gtransport->smart_options) {
2571+
/*
2572+
* Intentionally assign the address of a local variable
2573+
* to a non-local struct's field.
2574+
* codeql[cpp/stack-address-escape]
2575+
*/
25712576
gtransport->smart_options->acked_commits = &acked_commits;
25722577
} else {
25732578
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
@@ -1913,6 +1913,9 @@ static int determine_submodule_update_strategy(struct repository *r,
19131913
const char *val;
19141914
int ret;
19151915

1916+
if (!sub)
1917+
return error(_("could not retrieve submodule information for path '%s'"), path);
1918+
19161919
key = xstrfmt("submodule.%s.update", sub->name);
19171920

19181921
if (update) {

commit-graph.c

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

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

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)