From fd068221b7fbbcfe89ec74c7eeb0138e90e14b13 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Wed, 18 Dec 2019 10:51:59 +0000
Subject: [PATCH] 45083: Add signal protection to execarith().
Otherwise we could get re-entrancy in memory functions when
setting variables.
---
ChangeLog | 5 +++++
Src/exec.c | 3 +++
2 files changed, 8 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index cc0ad1d8e..897114d3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-18 Peter Stephenson
+
+ * 45083: Src/exec.c: execarith() needs signal protection as
+ it sets variables.
+
2019-12-18 Daniel Shahaf
* 45076: Src/loop.c: internal: Simplify handling of
diff --git a/Src/exec.c b/Src/exec.c
index 50027654a..fac095d64 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5101,6 +5101,7 @@ execarith(Estate state, UNUSED(int do_exec))
mnumber val = zero_mnumber;
int htok = 0;
+ queue_signals();
if (isset(XTRACE)) {
printprompt4();
fprintf(xtrerr, "((");
@@ -5120,6 +5121,8 @@ execarith(Estate state, UNUSED(int do_exec))
fprintf(xtrerr, " ))\n");
fflush(xtrerr);
}
+ unqueue_signals();
+
if (errflag) {
errflag &= ~ERRFLAG_ERROR;
return 2;