diff mbox series

[v2,1/6] test-ref-store: plug memory leak in cmd_delete_refs

Message ID 7fa5c247c8b1cdeb4fcd166cfb6e98425d21e5ae.1638211786.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Allow writing invalid OIDs into refs for testing purposes | expand

Commit Message

Han-Wen Nienhuys Nov. 29, 2021, 6:49 p.m. UTC
From: Han-Wen Nienhuys <hanwen@google.com>

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
 t/helper/test-ref-store.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Junio C Hamano Nov. 29, 2021, 11:15 p.m. UTC | #1
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Han-Wen Nienhuys <hanwen@google.com>
>
> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> ---
>  t/helper/test-ref-store.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
> index b314b81a45b..ccc2bb01bf3 100644
> --- a/t/helper/test-ref-store.c
> +++ b/t/helper/test-ref-store.c
> @@ -86,11 +86,13 @@ static int cmd_delete_refs(struct ref_store *refs, const char **argv)
>  	unsigned int flags = arg_flags(*argv++, "flags");
>  	const char *msg = *argv++;
>  	struct string_list refnames = STRING_LIST_INIT_NODUP;
> -
> +	int result;

Thanks, but let's not lose the blank line between the declarations
and the first statement, which serves for readability.

>  	while (*argv)
>  		string_list_append(&refnames, *argv++);
>  
> -	return refs_delete_refs(refs, msg, &refnames, flags);
> +	result = refs_delete_refs(refs, msg, &refnames, flags);
> +	string_list_clear(&refnames, 0);
> +	return result;
>  }
>  
>  static int cmd_rename_ref(struct ref_store *refs, const char **argv)
diff mbox series

Patch

diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index b314b81a45b..ccc2bb01bf3 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -86,11 +86,13 @@  static int cmd_delete_refs(struct ref_store *refs, const char **argv)
 	unsigned int flags = arg_flags(*argv++, "flags");
 	const char *msg = *argv++;
 	struct string_list refnames = STRING_LIST_INIT_NODUP;
-
+	int result;
 	while (*argv)
 		string_list_append(&refnames, *argv++);
 
-	return refs_delete_refs(refs, msg, &refnames, flags);
+	result = refs_delete_refs(refs, msg, &refnames, flags);
+	string_list_clear(&refnames, 0);
+	return result;
 }
 
 static int cmd_rename_ref(struct ref_store *refs, const char **argv)