aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--builtin.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index bb9cadf6..45ba7f6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2016-05-03 Andrew J. Schorr <aschorr@telemetry-investments.com>
+ * builtin.c (format_tree): Do not waste a byte at the end of a string.
+
+2016-05-03 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
* builtin.c (format_tree): After the string has been rendered, use
realloc to shrink the buffer to the needed size. Otherwise, the minimum
buffer size of 512 bytes can result in lots of wasted memory if many
diff --git a/builtin.c b/builtin.c
index 31c13a81..77314d48 100644
--- a/builtin.c
+++ b/builtin.c
@@ -722,7 +722,7 @@ format_tree(
emalloc(obuf, char *, INITIAL_OUT_SIZE, "format_tree");
obufout = obuf;
osiz = INITIAL_OUT_SIZE;
- ofre = osiz - 2;
+ ofre = osiz - 1;
cur_arg = 1;
@@ -1584,7 +1584,7 @@ mpf1:
bchunk(s0, s1 - s0);
olen_final = obufout - obuf;
if (ofre > 0)
- erealloc(obuf, char *, olen_final + 2, "format_tree");
+ erealloc(obuf, char *, olen_final + 1, "format_tree");
r = make_str_node(obuf, olen_final, ALREADY_MALLOCED);
obuf = NULL;
out: