"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
minor leak in list_refs
To:
gameoftrees@openbsd.org
Date:
Wed, 23 Mar 2022 19:41:59 +0100

Download raw body.

Thread
glancing at the code to get the list of refs i noticed this.  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? :)

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 *