summaryrefslogtreecommitdiff
path: root/src/post.cc
diff options
context:
space:
mode:
authorTavis Ormandy <taviso@gmail.com>2024-06-29 22:20:42 -0700
committerJohn Wiegley <johnw@newartisans.com>2024-07-08 10:10:04 -0700
commitbe541cbae2190545c14989c020d9d0c14b711880 (patch)
tree9855f8919b31b36495a0bd75e69ab4ae240cc0c1 /src/post.cc
parentd4e3c6be764dfa0d70fa96847d1325bcd37bc0cc (diff)
downloadfork-ledger-be541cbae2190545c14989c020d9d0c14b711880.tar.gz
fork-ledger-be541cbae2190545c14989c020d9d0c14b711880.tar.bz2
fork-ledger-be541cbae2190545c14989c020d9d0c14b711880.zip
Restore expr context after calc, #2330 #2343
Part of the expr_t::compile() process is to store the current scope, but In post_t::add_to_value that scope is temporary and on the stack. Restore the original context after that process is complete.
Diffstat (limited to 'src/post.cc')
-rw-r--r--src/post.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/post.cc b/src/post.cc
index 72930b46..e2063a36 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -642,11 +642,12 @@ void post_t::add_to_value(value_t& value, const optional<expr_t&>& expr) const
add_or_set_value(value, xdata_->compound_value);
}
else if (expr) {
- bind_scope_t bound_scope(*expr->get_context(),
- const_cast<post_t&>(*this));
+ scope_t *ctx = expr->get_context();
+ bind_scope_t bound_scope(*ctx, const_cast<post_t&>(*this));
#if 1
value_t temp(expr->calc(bound_scope));
add_or_set_value(value, temp);
+ expr->set_context(ctx);
#else
if (! xdata_) xdata_ = xdata_t();
xdata_->value = expr->calc(bound_scope);