diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-05-06 08:10:58 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-05-06 08:10:58 +0300 |
commit | d5e44f948f77d6b6d2e8c8db5efe2aade7d09c5d (patch) | |
tree | e38518d6c3000d1a5eeaedc113386db65147e2f2 /builtin.c | |
parent | 07794eb7f53842e58e606b3f267f5686c4464e34 (diff) | |
parent | 7eed1513d0834de26528551f990372a5c2674ef2 (diff) | |
download | egawk-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.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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: { |