builtin/credential: clear credential before exit

We never release memory associated with `struct credential`. Fix this and mark the corresponding test as leak free. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed May 27, 2024 at 13:46 UTC 96c1655095ae21040afe9d9c05cf42bb0fc03581
2 files changed +4
builtin/credential.c
+2
@@ -39,5 +39,7 @@ int cmd_credential(int argc, const char **argv, const char *prefix UNUSED)
39 } else {
40 usage(usage_msg);
41 }
42 +
43 + credential_clear(&c);
44 return 0;
45 }
t/t0300-credentials.sh
+2
@@ -1,6 +1,8 @@
1 #!/bin/sh
2
3 test_description='basic credential helper tests'
4 +
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-credential.sh
8