aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-10-19 11:27:38 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-10-19 11:27:38 +0300
commitb5a739de9d8ada25c4ce7cf5f365ecde89f470e5 (patch)
tree4402ebd505197be22946c14465036f0bdf7e7ae7 /src
parent4b2e0d1a143a62fdcb25e747891ce6784a946408 (diff)
downloadmailfromd-b5a739de9d8ada25c4ce7cf5f365ecde89f470e5.tar.gz
mailfromd-b5a739de9d8ada25c4ce7cf5f365ecde89f470e5.tar.bz2
Allocate exception buffer even if status.mf is not required
This fixes coredumps caused by calls to MF_THROW from built-in functions in scripts without the 'require status' statement. * src/exclist.c (fixup_exceptions): New function * src/mailfromd.h (fixup_exceptions): New proto. * src/gram.y: Call fixup_exceptions before setting up dataseg.
Diffstat (limited to 'src')
-rw-r--r--src/exclist.c17
-rw-r--r--src/gram.y1
-rw-r--r--src/mailfromd.h1
3 files changed, 18 insertions, 1 deletions
diff --git a/src/exclist.c b/src/exclist.c
index 40a8074b..f7e8577f 100644
--- a/src/exclist.c
+++ b/src/exclist.c
@@ -53,10 +53,25 @@ define_exception(struct literal *lit, struct mu_locus_range const *locus)
}
void
+fixup_exceptions(void)
+{
+ char namebuf[128];
+ struct mu_locus_range locus = MU_LOCUS_RANGE_INITIALIZER;
+ mu_locus_point_set_file(&locus.beg, __FILE__);
+ locus.beg.mu_line = __LINE__;
+ while (exception_count < mf_exception_count) {
+ snprintf(namebuf, sizeof namebuf, "#%d", exception_count);
+ define_exception(string_alloc(namebuf, strlen(namebuf)),
+ &locus);
+ }
+ mu_locus_range_deinit(&locus);
+}
+
+void
enumerate_exceptions(int (*efn)(const struct constant *cp,
const struct literal *lit,
void *data),
- void *data)
+ void *data)
{
struct exclist *p;
diff --git a/src/gram.y b/src/gram.y
index 2de129ed..bc1d2c39 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -489,6 +489,7 @@ input : program
if (error_count)
YYERROR;
apply_deferred_init();
+ fixup_exceptions();
dataseg_layout();
if (optimization_level)
regex_layout();
diff --git a/src/mailfromd.h b/src/mailfromd.h
index 527d4f96..5cc7136b 100644
--- a/src/mailfromd.h
+++ b/src/mailfromd.h
@@ -936,6 +936,7 @@ void enumerate_exceptions(int (*efn)(const struct constant *cp,
const struct literal *lit,
void *data),
void *data);
+void fixup_exceptions(void);
void free_exceptions(void);

Return to:

Send suggestions and report system problems to the System administrator.