mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
97613b9cb9
When initializing the transport helper in `transport_get()`, we allocate the name of the helper. We neither end up transferring ownership of the name, nor do we free it. The associated memory thus leaks. Fix this memory leak by freeing the string at the calling side in `transport_get()`. `transport_helper_init()` now creates its own copy of the string and thus can free it as required. An alterantive way to fix this would be to transfer ownership of the string passed into `transport_helper_init()`, which would avoid the call to xstrdup(1). But it does make for a more surprising calling convention as we do not typically transfer ownership of strings like this. Mark now-passing tests as leak free. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
28 lines
537 B
Bash
Executable File
28 lines
537 B
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='reftable HTTPD tests'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
. "$TEST_DIRECTORY"/lib-httpd.sh
|
|
|
|
start_httpd
|
|
|
|
REPO="$HTTPD_DOCUMENT_ROOT_PATH/repo"
|
|
|
|
test_expect_success 'serving ls-remote' '
|
|
git init --ref-format=reftable -b main "$REPO" &&
|
|
cd "$REPO" &&
|
|
test_commit m1 &&
|
|
>.git/git-daemon-export-ok &&
|
|
git ls-remote "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" | cut -f 2-2 -d " " >actual &&
|
|
cat >expect <<-EOF &&
|
|
HEAD
|
|
refs/heads/main
|
|
refs/tags/m1
|
|
EOF
|
|
test_cmp actual expect
|
|
'
|
|
|
|
test_done
|