Skip to content

Commit c800963

Browse files
peffgitster
authored andcommitted
fetch-pack, send-pack: clean up shallow oid array
When we call get_remote_heads() for protocol v0, that may populate the "shallow" oid_array, which must be cleaned up to avoid a leak at the program exit. The same problem exists for both fetch-pack and send-pack, but not for the usual transport.c code paths, since we already do this cleanup in disconnect_git(). Fixing this lets us mark t5542 as leak-free for the send-pack side, but fetch-pack will need some more fixes before we can do the same for t5539. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0c23f1a commit c800963

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

builtin/fetch-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,5 +294,6 @@ int cmd_fetch_pack(int argc,
294294
free_refs(fetched_refs);
295295
free_refs(remote_refs);
296296
list_objects_filter_release(&args.filter_options);
297+
oid_array_clear(&shallow);
297298
return ret;
298299
}

builtin/send-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,5 +343,6 @@ int cmd_send_pack(int argc,
343343
free_refs(remote_refs);
344344
free_refs(local_refs);
345345
refspec_clear(&rs);
346+
oid_array_clear(&shallow);
346347
return ret;
347348
}

t/t5542-push-http-shallow.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='push from/to a shallow clone over http'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910
. "$TEST_DIRECTORY"/lib-httpd.sh
1011
start_httpd

0 commit comments

Comments
 (0)