diff mbox series

[3/6] strbuf: use `strbuf_attach()` correctly

Message ID c21fd9b168ae8248954bc94896d283e9857702ef.1587240635.git.martin.agren@gmail.com (mailing list archive)
State New, archived
Headers show
Series strbuf: simplify `strbuf_attach()` usage | expand

Commit Message

Martin Ågren April 18, 2020, 8:18 p.m. UTC
Similar to earlier commits, don't pass in the same value for `len` and
`alloc` to `strbuf_attach()`. This string comes from
`reencode_string_iconv()` which ensures we have an extra byte at the
end.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 strbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/strbuf.c b/strbuf.c
index bb0065ccaf..deb338412e 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -152,7 +152,7 @@  int strbuf_reencode(struct strbuf *sb, const char *from, const char *to)
 	if (!out)
 		return -1;
 
-	strbuf_attach(sb, out, len, len);
+	strbuf_attach(sb, out, len, len + 1);
 	return 0;
 }