[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-882
From: |
Andrew J. Schorr |
Subject: |
[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-882-ga6df7af |
Date: |
Tue, 03 May 2016 16:32:20 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, gawk-4.1-stable has been updated
via a6df7afc605079df7d85318846a522ef64aaa44d (commit)
from ffb353c999bd3d5785b92a3aad78a96ff03a4ced (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=a6df7afc605079df7d85318846a522ef64aaa44d
commit a6df7afc605079df7d85318846a522ef64aaa44d
Author: Andrew J. Schorr <address@hidden>
Date: Tue May 3 12:31:52 2016 -0400
Fix sprintf memory leak by using realloc to shrink buffer to the proper
size.
diff --git a/ChangeLog b/ChangeLog
index c536622..8e9ef89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-05-03 Andrew J. Schorr <address@hidden>
+
+ * 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
+ sprintf results are stored in an array.
+
2016-05-02 Andrew J. Schorr <address@hidden>
* gawkapi.h (gawk_api_major_version, gawk_api_minor_version): Add
diff --git a/builtin.c b/builtin.c
index 108bcb8..d7101c2 100644
--- a/builtin.c
+++ b/builtin.c
@@ -660,7 +660,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;
@@ -1572,7 +1572,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 + 2, "format_tree");
+ r = make_str_node(obuf, olen_final, ALREADY_MALLOCED);
obuf = NULL;
out:
{
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 7 +++++++
builtin.c | 7 +++++--
2 files changed, 12 insertions(+), 2 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-882-ga6df7af,
Andrew J. Schorr <=