summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/one-true-awk/FIXES8
-rw-r--r--contrib/one-true-awk/lib.c4
-rw-r--r--contrib/one-true-awk/tran.c4
3 files changed, 12 insertions, 4 deletions
diff --git a/contrib/one-true-awk/FIXES b/contrib/one-true-awk/FIXES
index 01a54ef..2f39d48 100644
--- a/contrib/one-true-awk/FIXES
+++ b/contrib/one-true-awk/FIXES
@@ -25,6 +25,14 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
+Oct 23, 2007:
+ minor fix in lib.c: increase inputFS to 100, change malloc
+ for fields to n+1.
+
+ fixed memory fault caused by out of order test in setsval.
+
+ thanks to david o'brien, freebsd, for both fixes.
+
May 1, 2007:
fiddle in makefile to fix for BSD make; thanks to igor sobrado.
diff --git a/contrib/one-true-awk/lib.c b/contrib/one-true-awk/lib.c
index c306910..c9cc5d5 100644
--- a/contrib/one-true-awk/lib.c
+++ b/contrib/one-true-awk/lib.c
@@ -40,7 +40,7 @@ char *fields;
int fieldssize = RECSIZE;
Cell **fldtab; /* pointers to Cells */
-char inputFS[10] = " ";
+char inputFS[100] = " ";
#define MAXFLD 2
int nfields = MAXFLD; /* last allocated slot for $i */
@@ -58,7 +58,7 @@ static Cell dollar1 = { OCELL, CFLD, NULL, "", 0.0, FLD|STR|DONTFREE };
void recinit(unsigned int n)
{
if ( (record = (char *) malloc(n)) == NULL
- || (fields = (char *) malloc(n)) == NULL
+ || (fields = (char *) malloc(n+1)) == NULL
|| (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL
|| (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
FATAL("out of space for $0 and fields");
diff --git a/contrib/one-true-awk/tran.c b/contrib/one-true-awk/tran.c
index d8b4a47..c19ce94 100644
--- a/contrib/one-true-awk/tran.c
+++ b/contrib/one-true-awk/tran.c
@@ -332,10 +332,10 @@ char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
donerec = 1;
}
t = tostring(s); /* in case it's self-assign */
- vp->tval &= ~NUM;
- vp->tval |= STR;
if (freeable(vp))
xfree(vp->sval);
+ vp->tval &= ~NUM;
+ vp->tval |= STR;
vp->tval &= ~DONTFREE;
dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );
OpenPOWER on IntegriCloud