Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 2/5] trailer: display a trailer without its trailing newline

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:02:52

Jeff King [off-list ref] writes:
On Fri, Nov 07, 2014 at 07:50:49PM +0100, Christian Couder wrote:
quoted
diff --git a/trailer.c b/trailer.c
index 761b763..f4d51ba 100644
--- a/trailer.c
+++ b/trailer.c
@@ -583,8 +583,12 @@ static int parse_trailer(struct strbuf *tok,
struct strbuf *val, const char *tra
 	strbuf_addch(&seps, '=');
 	len = strcspn(trailer, seps.buf);
 	strbuf_release(&seps);
-	if (len == 0)
-		return error(_("empty trailer token in trailer '%s'"), trailer);
+	if (len == 0) {
+		struct strbuf sb = STRBUF_INIT;
+		strbuf_addstr(&sb, trailer);
+		strbuf_rtrim(&sb);
+		return error(_("empty trailer token in trailer '%s'"), sb.buf);
+	}
Doesn't this leak sb.buf?
Yes.  "%.*s" might be your friend.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help