summaryrefslogtreecommitdiff
path: root/contrib/one-true-awk
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2007-10-25 12:38:02 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2007-10-25 12:38:02 +0000
commit4afed873bc48a8605b5de7d787a342cb9998c036 (patch)
treee10cabad03d865b2317afe548c3ff7d70d6841ff /contrib/one-true-awk
parenteb2cd5e1df2de9af1c4510a396ab702d3e04719c (diff)
parentd2f6e4922057ff44b13f97a6f641d0aadc21ec1c (diff)
downloadsrc-test-4afed873bc48a8605b5de7d787a342cb9998c036.tar.gz
src-test-4afed873bc48a8605b5de7d787a342cb9998c036.zip
This commit was generated by cvs2svn to compensate for changes in r172958,
which included commits to RCS files with non-trunk default branches.
Notes
Notes: svn path=/head/; revision=172959
Diffstat (limited to 'contrib/one-true-awk')
-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 01a54ef8ce440..2f39d4827c101 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 c3069105ba8db..c9cc5d563b16b 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 d8b4a4775c09a..c19ce94302a2f 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) );