aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-05-06 08:10:58 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-05-06 08:10:58 +0300
commitd5e44f948f77d6b6d2e8c8db5efe2aade7d09c5d (patch)
treee38518d6c3000d1a5eeaedc113386db65147e2f2 /builtin.c
parent07794eb7f53842e58e606b3f267f5686c4464e34 (diff)
parent7eed1513d0834de26528551f990372a5c2674ef2 (diff)
downloadegawk-d5e44f948f77d6b6d2e8c8db5efe2aade7d09c5d.tar.gz
egawk-d5e44f948f77d6b6d2e8c8db5efe2aade7d09c5d.tar.bz2
egawk-d5e44f948f77d6b6d2e8c8db5efe2aade7d09c5d.zip
Merge branch 'master' into feature/cmake
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/builtin.c b/builtin.c
index 4256ee5e..77314d48 100644
--- a/builtin.c
+++ b/builtin.c
@@ -670,7 +670,7 @@ format_tree(
int i, nc;
bool toofew = false;
char *obuf, *obufout;
- size_t osiz, ofre;
+ size_t osiz, ofre, olen_final;
const char *chbuf;
const char *s0, *s1;
int cs1;
@@ -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;
@@ -1582,7 +1582,10 @@ mpf1:
_("too many arguments supplied for format string"));
}
bchunk(s0, s1 - s0);
- r = make_str_node(obuf, obufout - obuf, ALREADY_MALLOCED);
+ olen_final = obufout - obuf;
+ if (ofre > 0)
+ erealloc(obuf, char *, olen_final + 1, "format_tree");
+ r = make_str_node(obuf, olen_final, ALREADY_MALLOCED);
obuf = NULL;
out:
{