aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2019-08-15 21:19:50 +0300
committerArnold D. Robbins <arnold@skeeve.com>2019-08-15 21:19:50 +0300
commit98e500ff3ceb035d9d42acf25aa365940cf47568 (patch)
tree8c33627bfe255de53f76d4e38f3fe07ca58d15dc /builtin.c
parentc7c3998ed9d96b61d03c675b2105ca5da77b9bfd (diff)
downloadegawk-98e500ff3ceb035d9d42acf25aa365940cf47568.tar.gz
egawk-98e500ff3ceb035d9d42acf25aa365940cf47568.tar.bz2
egawk-98e500ff3ceb035d9d42acf25aa365940cf47568.zip
Avoid memory growth in format_tree.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin.c b/builtin.c
index 1c205aa4..503a386c 100644
--- a/builtin.c
+++ b/builtin.c
@@ -685,7 +685,7 @@ format_tree(
int i, nc;
bool toofew = false;
char *obuf, *obufout;
- size_t osiz, ofre, olen_final;
+ size_t osiz, ofre;
const char *chbuf;
const char *s0, *s1;
int cs1;
@@ -1646,10 +1646,7 @@ mpf1:
_("too many arguments supplied for format string"));
}
bchunk(s0, s1 - s0);
- olen_final = obufout - obuf;
- if (ofre > 0)
- erealloc(obuf, char *, olen_final + 1, "format_tree");
- r = make_str_node(obuf, olen_final, ALREADY_MALLOCED);
+ r = make_str_node(obuf, obufout - obuf, ALREADY_MALLOCED);
obuf = NULL;
out:
{