Skip to content

Commit 076e5a1

Browse files
committed
fetch: silence a CodeQL alert about a local variable's address' use after release
As pointed out by CodeQL, it is a potentially dangerous practice to store local variables' addresses in non-local structs. My original intention was to make sure to clear it out after it was used, and before the function returns (which is when the address would go stale). However, I faced too much resistance in the Git project against such patches, there seemed to always be the overwhelming sentiment that the code isn't broken (even if it requires a complex and demanding analysis to wrap one's head around _that_). Therefore, I will be pragmatic and simply ask CodeQL to hold its peace about this issue forever. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 0a65ee6 commit 076e5a1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

builtin/fetch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,6 +2582,11 @@ int cmd_fetch(int argc,
25822582
die(_("must supply remote when using --negotiate-only"));
25832583
gtransport = prepare_transport(remote, 1);
25842584
if (gtransport->smart_options) {
2585+
/*
2586+
* Intentionally assign the address of a local variable
2587+
* to a non-local struct's field.
2588+
* codeql[cpp/stack-address-escape]
2589+
*/
25852590
gtransport->smart_options->acked_commits = &acked_commits;
25862591
} else {
25872592
warning(_("protocol does not support --negotiate-only, exiting"));

0 commit comments

Comments
 (0)