builtin/credential-store: fix leaking credential

We never free credentials read by the credential store, leading to a memory leak. Plug it. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Aug 1, 2024 at 12:40 UTC 1d615afa8d5297dcb8e12d603714f03fb2f0441b
3 files changed +4
builtin/credential-store.c
+1
@@ -218,5 +218,6 @@ int cmd_credential_store(int argc, const char **argv, const char *prefix)
218 ; /* Ignore unknown operation. */
219
220 string_list_clear(&fns, 0);
221 + credential_clear(&c);
222 return 0;
223 }
t/t0302-credential-store.sh
+2
@@ -1,6 +1,8 @@
1 #!/bin/sh
2
3 test_description='credential-store tests'
4 +
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-credential.sh
8
t/t0303-credential-external.sh
+1
@@ -29,6 +29,7 @@ you can set GIT_TEST_CREDENTIAL_HELPER_SETUP to a sequence of shell
29 commands.
30 '
31
32 +TEST_PASSES_SANITIZE_LEAK=true
33 . ./test-lib.sh
34 . "$TEST_DIRECTORY"/lib-credential.sh
35