Module Name: src
Committed By: christos
Date: Mon Dec 10 19:49:05 UTC 2012
Modified Files:
src/external/historical/nawk/dist: tran.c
Log Message:
PR/47306: Aleksey Cheusov: Don't free strings of symbols where we maintain
pointers to.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/historical/nawk/dist/tran.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/historical/nawk/dist/tran.c
diff -u src/external/historical/nawk/dist/tran.c:1.5 src/external/historical/nawk/dist/tran.c:1.6
--- src/external/historical/nawk/dist/tran.c:1.5 Sat May 28 11:13:04 2011
+++ src/external/historical/nawk/dist/tran.c Mon Dec 10 14:49:05 2012
@@ -71,6 +71,18 @@ Cell *literal0;
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 @@ char *setsval(Cell *vp, const char *s) /
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 @@ static char *get_str_val(Cell *vp, char
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);