aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2020-07-03 11:16:02 +0300
committerArnold D. Robbins <arnold@skeeve.com>2020-07-03 11:16:02 +0300
commitf60ced696bc752cdc1a1f45ce2cc9d6149be7087 (patch)
treea6294c9607f4964212c10daa3b1dde3501bf4d86
parentc93888d0bc6a1170edaac3f8cee4e13aac2abda9 (diff)
downloadegawk-f60ced696bc752cdc1a1f45ce2cc9d6149be7087.tar.gz
egawk-f60ced696bc752cdc1a1f45ce2cc9d6149be7087.tar.bz2
egawk-f60ced696bc752cdc1a1f45ce2cc9d6149be7087.zip
Fix double free error with -M.
-rw-r--r--ChangeLog9
-rw-r--r--field.c8
2 files changed, 17 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 394b0ed4..efe4abea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-07-03 Arnold D. Robbins <arnold@skeeve.com>
+
+ Fix a double free error with -M. Thanks to
+ "NIDE, Naoyuki" <nide@ics.nara-wu.ac.jp> for the report.
+
+ * field.c (clear_mpfr): New macro, clears MPFR and NUMCUR bits.
+ (reset_record): Use it on the newly copied field values.
+ (purge_record): Add introductory comment since we're in the file.
+
2020-07-01 Arnold D. Robbins <arnold@skeeve.com>
* eval.c (posix_compare): Rewrite contributed by
diff --git a/field.c b/field.c
index 0e84447a..c21046b9 100644
--- a/field.c
+++ b/field.c
@@ -90,6 +90,8 @@ Regexp *FPAT_re_no_case = NULL;
Regexp *FPAT_regexp = NULL;
NODE *Null_field = NULL;
+#define clear_mpfr(n) ((n)->flags &= ~(MPFN | MPZN | NUMCUR))
+
/* init_fields --- set up the fields array to start with */
void
@@ -230,6 +232,7 @@ rebuild_record()
}
n->stptr = cops;
+ clear_mpfr(n);
unref(r);
fields_arr[i] = n;
assert((n->flags & WSTRCUR) == 0);
@@ -347,6 +350,11 @@ reset_record()
}
}
+/*
+ * purge_record --- throw away the fields, make sure that
+ * individual nodes remain valid.
+ */
+
static void
purge_record()
{