Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/historical/nawk/dist PR/47306: Aleksey Cheusov: Don...
details: https://anonhg.NetBSD.org/src/rev/125d2847e260
branches: trunk
changeset: 783199:125d2847e260
user: christos <christos%NetBSD.org@localhost>
date: Mon Dec 10 19:49:05 2012 +0000
description:
PR/47306: Aleksey Cheusov: Don't free strings of symbols where we maintain
pointers to.
diffstat:
external/historical/nawk/dist/tran.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diffs (41 lines):
diff -r c6fcea2e8298 -r 125d2847e260 external/historical/nawk/dist/tran.c
--- a/external/historical/nawk/dist/tran.c Mon Dec 10 18:11:33 2012 +0000
+++ b/external/historical/nawk/dist/tran.c Mon Dec 10 19:49:05 2012 +0000
@@ -71,6 +71,18 @@
extern Cell **fldtab;
+static void
+setfree(Cell *vp)
+{
+ if (&vp->sval == FS || &vp->sval == RS ||
+ &vp->sval == OFS || &vp->sval == ORS ||
+ &vp->sval == OFMT || &vp->sval == CONVFMT ||
+ &vp->sval == FILENAME || &vp->sval == SUBSEP)
+ vp->tval |= DONTFREE;
+ else
+ vp->tval &= ~DONTFREE;
+}
+
void syminit(void) /* initialize symbol table with builtin vars */
{
literal0 = setsymtab("0", "0", 0.0, NUM|STR|CON|DONTFREE, symtab);
@@ -349,7 +361,7 @@
xfree(vp->sval);
vp->tval &= ~NUM;
vp->tval |= STR;
- vp->tval &= ~DONTFREE;
+ setfree(vp);
dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );
@@ -400,8 +412,8 @@
else
snprintf(s, sizeof(s), *fmt, vp->fval);
vp->sval = tostring(s);
- vp->tval &= ~DONTFREE;
vp->tval |= STR;
+ setfree(vp);
}
dprintf( ("getsval %p: %s = \"%s (%p)\", t=%o\n", vp, NN(vp->nval), vp->sval, vp->sval, vp->tval) );
return(vp->sval);
Home |
Main Index |
Thread Index |
Old Index