Skip to content

Commit 05372c2

Browse files
peffgitster
authored andcommitted
send-pack: free cas options before exit
The send-pack --force-with-lease option populates a push_cas_option struct with allocated strings. Exiting without cleaning this up will cause leak-checkers to complain. We can fix this by calling clear_cas_option(), after making it publicly available. Previously it was used only for resetting the list when we saw --no-force-with-lease. The git-push command has the same "leak", though in this case it won't trigger a leak-checker since it stores the push_cas_option struct as a global rather than on the stack (and is thus reachable even after main() exits). I've added cleanup for it here anyway, though, as future-proofing. The leak is triggered by t5541 (it tests --force-with-lease over http, which requires a separate send-pack process under the hood), but we can't mark it as leak-free yet. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 753f670 commit 05372c2

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

builtin/push.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ int cmd_push(int argc,
669669
rc = do_push(flags, push_options, remote);
670670
string_list_clear(&push_options_cmdline, 0);
671671
string_list_clear(&push_options_config, 0);
672+
clear_cas_option(&cas);
672673
if (rc == -1)
673674
usage_with_options(push_usage, options);
674675
else

builtin/send-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,5 +344,6 @@ int cmd_send_pack(int argc,
344344
free_refs(local_refs);
345345
refspec_clear(&rs);
346346
oid_array_clear(&shallow);
347+
clear_cas_option(&cas);
347348
return ret;
348349
}

remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,7 @@ struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map)
25442544
/*
25452545
* Compare-and-swap
25462546
*/
2547-
static void clear_cas_option(struct push_cas_option *cas)
2547+
void clear_cas_option(struct push_cas_option *cas)
25482548
{
25492549
int i;
25502550

remote.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ struct push_cas_option {
409409
};
410410

411411
int parseopt_push_cas_option(const struct option *, const char *arg, int unset);
412+
void clear_cas_option(struct push_cas_option *);
412413

413414
int is_empty_cas(const struct push_cas_option *);
414415
void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);

0 commit comments

Comments
 (0)