Download raw body.
minor leak in list_refs
On Wed, Mar 23, 2022 at 07:41:59PM +0100, Omar Polo wrote:
> glancing at the code to get the list of refs i noticed this.
ok stsp@
> list_refs
> is static in got.c and only used by cmd_ref; if it fails we bail out and
> exit immediately. maybe i'm too pedantic? :)
No. Code can be copied around and lingering bugs like this could
take effect as a result.
> diff 08d508671c852e8968d71eba2642ee1934469425 /home/op/w/got
> blob - fb5211d500574e714e2964dd6a9ab1ac8433e57d
> file + got/got.c
> --- got/got.c
> +++ got/got.c
> @@ -5656,14 +5656,16 @@ list_refs(struct got_repository *repo, const char *ref
> TAILQ_FOREACH(re, &refs, entry) {
> char *refstr;
> refstr = got_ref_to_str(re->ref);
> - if (refstr == NULL)
> - return got_error_from_errno("got_ref_to_str");
> + if (refstr == NULL) {
> + err = got_error_from_errno("got_ref_to_str");
> + break;
> + }
> printf("%s: %s\n", got_ref_get_name(re->ref), refstr);
> free(refstr);
> }
>
> got_ref_list_free(&refs);
> - return NULL;
> + return err;
> }
>
> static const struct got_error *
>
>
minor leak in list_refs