aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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()
{