Skip to content

Commit 77506db

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 <[email protected]>
1 parent 1c2e825 commit 77506db

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
@@ -2567,6 +2567,11 @@ int cmd_fetch(int argc,
25672567
die(_("must supply remote when using --negotiate-only"));
25682568
gtransport = prepare_transport(remote, 1);
25692569
if (gtransport->smart_options) {
2570+
/*
2571+
* Intentionally assign the address of a local variable
2572+
* to a non-local struct's field.
2573+
* codeql[cpp/stack-address-escape]
2574+
*/
25702575
gtransport->smart_options->acked_commits = &acked_commits;
25712576
} else {
25722577
warning(_("protocol does not support --negotiate-only, exiting"));

0 commit comments

Comments
 (0)