[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-479
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-479-gb4cf3cc |
Date: |
Tue, 11 Nov 2014 21:12:26 +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 b4cf3cc470eb1200ec90fcc7ad5b2d069059cf7e (commit)
from 350265fafb2a0153d4207c67d626f135b308ad34 (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=b4cf3cc470eb1200ec90fcc7ad5b2d069059cf7e
commit b4cf3cc470eb1200ec90fcc7ad5b2d069059cf7e
Author: Arnold D. Robbins <address@hidden>
Date: Tue Nov 11 23:12:01 2014 +0200
Fix memory growth problem.
diff --git a/ChangeLog b/ChangeLog
index 4f21f0f..3049827 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-11-11 Arnold D. Robbins <address@hidden>
+
+ Don't let memory used increase linearly in the size of
+ the input. Problem reported by dragan legic
+ <address@hidden>.
+
+ * field.c (set_record): NUL-terminate the buffer.
+ * interpret.h (r_interpret): Op_field_spec: if it's $0, increment
+ the valref. Op_store_var: if we got $0, handle it appropriately.
+
2014-11-10 Arnold D. Robbins <address@hidden>
Reorder main.c activities so that we can set a locale on the
diff --git a/field.c b/field.c
index 4819ea9..7b4f219 100644
--- a/field.c
+++ b/field.c
@@ -277,6 +277,12 @@ set_record(const char *buf, int cnt)
/* copy the data */
memcpy(databuf, buf, cnt);
+ /*
+ * Add terminating '\0' so that C library routines
+ * will know when to stop.
+ */
+ databuf[cnt] = '\0';
+
/* manage field 0: */
unref(fields_arr[0]);
getnode(n);
diff --git a/interpret.h b/interpret.h
index 2880433..593f11a 100644
--- a/interpret.h
+++ b/interpret.h
@@ -340,7 +340,12 @@ uninitialized_scalar:
lhs = r_get_field(t1, (Func_ptr *) 0, true);
decr_sp();
DEREF(t1);
- r = dupnode(*lhs); /* can't use UPREF here */
+ /* only for $0, up ref count */
+ if (*lhs == fields_arr[0]) {
+ r = *lhs;
+ UPREF(r);
+ } else
+ r = dupnode(*lhs);
PUSH(r);
break;
@@ -649,11 +654,22 @@ mod:
lhs = get_lhs(pc->memory, false);
unref(*lhs);
r = pc->initval; /* constant initializer */
- if (r == NULL)
- *lhs = POP_SCALAR();
- else {
+ if (r != NULL) {
UPREF(r);
*lhs = r;
+ } else {
+ r = POP_SCALAR();
+
+ /* if was a field, turn it into a var */
+ if ((r->flags & FIELD) == 0) {
+ *lhs = r;
+ } else if (r->valref == 1) {
+ r->flags &= ~FIELD;
+ *lhs = r;
+ } else {
+ *lhs = dupnode(r);
+ DEREF(r);
+ }
}
break;
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 10 ++++++++++
field.c | 6 ++++++
interpret.h | 24 ++++++++++++++++++++----
3 files changed, 36 insertions(+), 4 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-479-gb4cf3cc,
Arnold Robbins <=